How To Remove First Element of Array in PHP - array_shift() Function

PHP Array Functions

You can use the array_shift() function to remove the first element or value from an array. The array_shift() function returns the removed first value of array. If the array is empty (or the variable is not an array), the returned value is NULL.

images/articles/php/remove-first-element-of-array-in-php-array-shift.jpg

This function shifts an element off the beginning of array.

Example:

$planets = array("Mercury", "Venus", "Earth", "Mars");

// Removing first array item
$planet = array_shift($planets);