In case you do not know what the first item's key is:
// Make sure to reset the array's current index
reset($array);
array);
unset($array[$key]);
Answer from aefxx on Stack OverflowPHP
php.net › manual › en › function.array-shift.php
PHP: array_shift - Manual
<?php function array_last_entry($arr){ if(!is_array($arr)) return; if(empty($arr)) return; return end($arr); } function array_first_entry($arr){ if(!is_array($arr)) return; if(empty($arr)) return; reset($arr); return current($arr); } $arr = array( '5' => 'five', '3' => 'three', '8' => 'eight',); echo 'last entry: '.array_last_entry($arr).'<br>'; echo 'first entry: '.array_first_entry($arr).'<br>'; echo 'alternative output:<br>'; echo 'last entry: '.$arr[count($arr)-1]; echo '<br>first entry: '.$arr[0]; ?> The output will look like: last entry: eight first entry: five alternative output: last entry: first entry: As you can see, if you have to handle arrays with non-continuous indexes, these functions may be very helpful. ... no, it demonstrates quite well that it removes the first element in the original array, updating the keys, and that it also returns the original first element.
W3Schools
w3schools.com › php › func_array_shift.asp
PHP array_shift() Function
❮ PHP Array Reference · Remove ...een","c"=>"blue"); echo array_shift($a); print_r ($a); ?> Try it Yourself » · The array_shift() function removes the first element from an array, and returns the value of the removed ...
PHP: Remove the first and last item of the array - Stack Overflow
Suppose I have this array: $array = array('10', '20', '30.30', '40', '50'); Questions: What is the fastest/easiest way to remove the first item from the above array? What is the fastest/easiest ... More on stackoverflow.com
Skip / remove the first row of array - PHP - SitePoint Forums | Web Development & Design Community
Hi, Im struggling to skip / remove the first row of results from my array Currently: images AS $image) { I tried this but it causes an error. Parse error: syntax error, unexpected T_UNSET in More on sitepoint.com
How to remove an array from an array of arrays, and move its child array to its parent array (php)
Solved it by using this twice: array_reduce($array, 'array_merge', array()); Turns out formulating it for posting really helps getting a good term to google! More on reddit.com
Easy way to remove all elements of an associative array with specified key?
First I'd question where this array is coming from. If it's coming from a database, then you should handle this in the query by not grabbing the id column. Otherwise, you can just loop through them and unset the key. Note the & is important here: foreach($array as &$item) { unset($item['id']); } More on reddit.com
What is the use of array_shift in PHP?
$fruits = ['apple', 'banana', 'cherry'];
$first = array_shift($fruits);
print_r($fruits); // ['banana', 'cherry']
echo $first; // apple
It removes the first element from the array and returns it.flatcoding.com
flatcoding.com › home › php array_shift: remove the first array element with examples
PHP array_shift: Remove the First Array Element with Examples - ...
What is the difference between array_shift and array_pop?
$arr = [1, 2, 3];
array_shift($arr); // removes 1 from start
array_pop($arr); // removes last element
array_shift removes from the beginning, array_pop removes from the end.flatcoding.com
flatcoding.com › home › php array_shift: remove the first array element with examples
PHP array_shift: Remove the First Array Element with Examples - ...
How does array_shift work with associative arrays?
$user = ['name' => 'John', 'age' => 25];
$first = array_shift($user);
print_r($user); // ['age' => 25]
echo $first; // John
It removes the first key-value pair based on internal order.flatcoding.com
flatcoding.com › home › php array_shift: remove the first array element with examples
PHP array_shift: Remove the First Array Element with Examples - ...
Videos
Array remove first element in PHP
03:58
Remove First Element from an Array in Verse Code - YouTube
06:06
PHP: How to delete an element from an array in PHP? - YouTube
04:17
PHP, Remove First Element of Array with array_shift, Add Element ...
04:09
JavaScript Array - 06 - Remove the first element - YouTube
17:15
PHP Add To and Remove Elements From an Array - YouTube
Top answer 1 of 4
48
In case you do not know what the first item's key is:
// Make sure to reset the array's current index
reset($array);
array);
unset($array[$key]);
2 of 4
8
$array=array("a"=>"123","b"=>"234","c"=>"345");
unset($array["a"]) ;
var_dump($array) ;
Also, what version of PHP do you use?
array_shift works fine for me with string-indexed arrays and I get the expected result.
GeeksforGeeks
geeksforgeeks.org › php › how-to-remove-first-element-from-an-array-in-php
How to Remove First Element from an Array in PHP? - GeeksforGeeks
July 23, 2025 - Given an Array, the task is to remove the first element from the array in PHP. There are three methods to remove the first element from an array, these are - using array_shift(), array_slice(), and unset() functions.
Top answer 1 of 7
81
Using array_slice is simplest
$newarray = array_slice($array, 1, -1);
If the input array has less than 3 elements in it, the output array will be empty.
2 of 7
73
To remove the first element, use array_shift, to remove last element, use array_pop:
<?php
$array = array('10', '20', '30.30', '40', '50');
array_shift($array);
array_pop($array);
W3Schools
w3schools.com › php › php_arrays_remove.asp
PHP Remove Array Items
In PHP, you can remove/delete array ... an associative array · array_pop() - removes the last array item · array_shift() - removes the first array item ·...
TecAdmin
tecadmin.net › removing-first-element-from-array-in-php
Removing the First Element from an Array in PHP – TecAdmin
April 26, 2025 - The `array_shift()` function in PHP removes the first element or value from an array and returns that value.
PHP Tutorial
phptutorial.net › home › php tutorial › php array_shift
PHP array_shift() Function
April 7, 2025 - In this example, the array_shift() function removes the first element of the $scores array and returns the value of the element, which is "A". It also preserves the keys in the array. Use the PHP array_shift() function to remove an array from the beginning of an array and return it.