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 Overflow
🌐
PHP
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 ...
Discussions

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
🌐 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
🌐 sitepoint.com
0
February 4, 2010
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
🌐 r/learnprogramming
1
6
January 15, 2023
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
🌐 r/PHPhelp
10
3
August 21, 2019
People also ask

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 - ...
🌐
GeeksforGeeks
geeksforgeeks.org › php › remove-first-element-from-an-array-in-php
Remove First Element from an Array in PHP - GeeksforGeeks
July 23, 2025 - The array_shift() function removes the first element from an array and returns it. This function also re-indexes the array so that the keys start from 0 again. Example: This example shows the implementation of the above-explained approach.
🌐
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.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-remove-the-first-element-from-an-array-in-php.php
How to Remove the First Element from an Array in PHP
You can use the PHP array_shift() function to remove the first element or value from an array. The array_shift() function also returns the removed value of array.
Find elsewhere
🌐
FlatCoding
flatcoding.com › home › php array_shift: remove the first array element with examples
PHP array_shift: Remove the First Array Element with Examples - FlatCoding
September 7, 2025 - The array_shift function in PHP takes the first element from an array and returns it. It also moves all other elements down by one position. The original array changes because array_shift works directly on it.
🌐
Sentry
sentry.io › sentry answers › php › deleting elements from an array in php
Deleting elements from an array in PHP | Sentry
If you want to delete an element from an array but you only know its value, you can use array_search() to find the key of the element, and then use unset() to remove the key-value pair.
🌐
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.
🌐
SitePoint
sitepoint.com › php
Skip / remove the first row of array - PHP - SitePoint Forums | Web Development & Design Community
February 4, 2010 - Hi, Im struggling to skip / remove the first row of results from my array Currently: <?php foreach($this->images AS $image) { I tried this but it causes an error. Parse error: syntax error, unexpected T_UNSET in <?…
🌐
The Code Developer
thecodedeveloper.com › home › php › how to remove the first element from an array in php
How to Remove the First element from an array in PHP - PHP Tutorial
December 1, 2018 - You can use the PHP array_shift() function remove the first element from an array in PHP. The array_shift() function returns the first value of the array.
🌐
ItSolutionstuff
itsolutionstuff.com › post › how-to-remove-first-element-from-array-in-phpexample.html
How to Remove First Element from Array in PHP? - ItSolutionstuff.com
May 14, 2024 - This article goes in detailed on how to remove first element from array in php. you can understand a concept of remove first item from array in php. let’s discuss about php remove first element from array. We will use php remove first item from array.
🌐
Techfry
techfry.com › home › php tutorial › how to remove first element of array in php - array_shift() function
How To Remove First Element of Array in PHP - array_shift() Function - Tech Fry
June 24, 2023 - 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.
🌐
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.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › shift
JavaScript Array shift() - Remove First Element | Vultr Docs
November 25, 2024 - In this article, you will learn how to effectively use the shift() method to manage and manipulate arrays. Explore practical examples that illustrate how to remove elements from the beginning of an array and how this impacts the array's structure ...