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.


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

// Removing first array item
$planets_new = array_shift($planets);
Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive