PHP Snippets

Load CSV Into a 2-d Array Using PHP - Code shows how to load a CSV file into a two-dimensional PHP array.

Convert a PHP 2d-Array to CSV - Convert a 2-dimensional PHP array into a CSV string

Load CSV File Into PHP 1-d Array - Loads a flat csv file into a php array as a one-dimensional array.

Calculate Script Execution Time - Calculate the time it takes to execute a PHP script.

Round a PHP 2d Array by a Specified Key - Round a 2-dimensional array by a key. For example, sort array[$i][2] sorts all $i by the 2nd key.

Get the Distance Between Two Points in Latitude and Longitude - Find the distance between two sets of latitude and longitude points.

Loop for a Period of Time - Loop for a period of time, performing calculations. When specified time period has elapsed exit the loop.

Loop Structures in PHP - Illustrates several looping structures in PHP for various conditions.

Use PHP to Get the Links from an HTML Page - Get the links from an HTML page using PHP

Remove the Last Character From a PHP String - Remove the last character from a string in PHP

Determine if PHP String Contains a Substring - PHP function returns boolean true if the substring is contained in the string.

Insert an Element into a PHP Array - Insert a new element into a PHP array at a given location, reordering the array.

Get Contents of Directory in PHP - Retrieve the contents of a directory on the server and put the contents in an array.