How do I remove the first element from an array?
Often you want to add or remove values from the start or end of an array. To remove the first value in the array and see what it is, you can use the array_shift function in PHP:
$values = array(1,2,3,4,5,6,7,8,9,10);
$first = array_shift($values);
echo "First value was: $first";
Which tells us this:
First value was: 1
 => 2
 => 3
 => 4
 => 5
 => 6
 => 7
 => 8
 => 9
 => 10
Notice how the keys get re-assigned after the call to array_shift, so that '2' now has a key of zero whereas in the initial array that key referenced the number '1' which has now been removed from the array.
More arrays PHP Questionsin .$array->description doesn't work "description" is suppose to stay black and turns colored and is ignored Why?
How do I add to the beginning of an array and find the number of elements in it?
How do we sort an array of names taken from a text file, displaying only unique names?
I am not interested in the values in the arrays, how can I discard them?
How can I reverse sort an array keeping the correlation between the index and value?