Tagged with PHP

PHP Store Locator

Just getting some code out of my wiki. The Google Maps API part won’t work, but there is some nice distance functions and the overall concept is fine. Just needs an update on the Google Maps API.


Cache Function for PHP

This is a fantastic function that will allow you to cache your data. By default it will cache using memcache, however if you do not have memcache installed or a connection cannot be achieved it will fall back to file based cache.

The single function supports cache read, cache write, cache clear key and cache clear all. The cached data can be given an expirey time so that your data does not become stale.

Usage is very simple and the performance results of caching using memcache are fantastic.


How to Enable Register Globals in PHP 5

If you understand the potential security risks but you still need to run PHP with register_globals ON there are a couple of ways to do it.

If you have access to the servers php.ini then its fairly easy, however if you don’t have access to that file or if you are not willing to make this change server wide then there are other ways to go about it.


Monitor Multiple MySQL Servers using PHP

This is a quick 1 page application to monitor your replicated MySQL servers.

Use it as you will. Enjoy!


Load CSV or Delimited Data from a File into a Named Array

This small snippet will allow you to load CSV or other delimited Data from a File into a named array. The heads in the CSV file will be used for the names of the array keys.


Regular Expression for Date or Datetime Validation

This Regular Expression will verify if a date is a valid YYYY-MM-DD with an optional HH:MM:SS. It checks to see if the day is a valid day in the given month with the consideration of leap years.


Merge Your CSS and JavaScript Using PHP

Merge all of your CSS and JS into one file to improve server speed.


Word Permutator Function

Give this function a phrase and it will return all of the permutations of the words that make up the phrase.


Image Cache using phpThumb and Mod_Rewrite

Generate thumbs by visiting a URL such as your.com/thumbs/50x50/images/image.jpg. This will create a 50x50px thumbnail of your.com/images/image.jpg.

The thumb will be stored on your server at your.com/thumbs/50x50/images/image.jpg so the next request for the same image will be loaded without loading php for ultra fast image cache.


Remove Array Nulls

Recursively removes array keys with null values.


Deep In Array

Function similar to in_array() but it recursively searches a multi-depth array.


Deep Array Reverse

Recursively reverses a multi-depth array.


URL Reader

This function will download the contents of any URL and return it as a string that you can save to a file or database.

It will use curl if it is installed. Otherwise it will use fopen/fread.