Custom PHP functions and code snippets
Find on this site PHP code snippets and useful functions. The code here will show you common functionality in PHP and MySQL packed mostly in PHP functions or in easy to use and well commented code blocks. Just click the name to show the code snippet and his description. You're welcome to tell us about your comments, suggestions and questions.
We offer also a selection of powerful PHP classes, they are free to download as well.
PHP Snippet and function list
- RSS parser with cache function
A script for caching and parsing RSS files using SimpleXML and php file functions - Dynamic radio group (HTML)
A php function to create a group of HTML radio elements - PHP URL / domain name splitter
Split with this snippet a full domain name into sub-domain, domain and tld - Custom error page / report
http error reporting script to report errors into the webmasters e-mail - Nested Select menu using "optgroup"
Create nested xhtml valid select menu with option groups on the fly - Directories filenames to database
A simple script to copy the filenames of a directory into a database table - Cross-Browser Session Starter
This handy function will start and update a cross-browser php session cookie - (Back) link checker - Demo
Use this function to heck if a link to a website in the code of an url really exists. - HTML head section, parse META data - Demo
Parse information from existing title and meta elements from a remote html document - Alternative colored rows - Demo
php code snippet to create alternative colored rows for mysql/array data inside the html - Database resultset navigation
Easy to use PHP function to create back- forward links for a result set - PHP Directories oldest file - Demo
A small php function to select the oldest file inside a specific directory. - Regular expression patterns - Demo
Samples of regular expression patterns to validate decimals, dutch postal code and an e-mail address - CSS style switcher
simple extensible CSS style sheet switcher using PHP sessions - Select menu with DB values
Function to create dynamically a select menu from a mysql database result set - PHP Nested Loop snippet - Demo
Database result set in a nested repeat region inside a html table (using mysql and php) - Long string protection - Demo
This function can handle long string with to much the same chars in a row - E-mail address validation
Advanced e-mail validation while checking DNS entries (mx records) - Parse Template Monster data - Demo
Simple script to obtain data from the template monster api and show a sample result - Dynamic form field
Simple text type input fields control in your (CMS) form - Daily (random) banner
This simple banner system will show a different banner each day.
Find more snippets, custom functions and PHP code on our forum. We share new PHP scripts and tutorials frequently on both our forum and on the web development blog!
Try Shopping Cart Software for online businesses of all types and sizes.