A steadily growing collection of handy PHP code snippets that you should find useful!
- Add numbers to MySQL database results.
- Get the id of an auto_incrementing id from a mysql insert
- Remove all characters except letters and numbers from a string
- Calculate VAT on a price and round to two decimal places
- Check that characters in a variable are alpha numeric using ereg
- Verify using ereg that characters in a variable only contain numbers
- Use ereg to check that characters in a variable only contain letters
- Count and display the number of rows in a mysql database table
- How to include a file in PHP
- Remove white space from a text string using the PHP trim function
- Count the number of lines in a text file
- Limit the length of a text string being entered into a database
- Find and replace words in a text string using str_replace
- Count number of words in a text string
- Date and time a file was last accessed
- Number of days between now and a day in the future
- Convert links into clickable hyperlinks
- Create a random password
- Write data to a text file
- Send email using the PHP mail() function
- Delete data from a MySQL database
- Add data to a MySQL database
- Validate an email address using regular expressions
- Display date and time with PHP
- Connect to a MySQL database
- Shorten a text string
- Server information
- Word wrap
- Page redirect
- Date file last modified
- Visitor information
- Page load time
REFERENCE
http://www.totallyphp.co.uk/code/