array_shift()
functionYou 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. However, if the array is empty (or the variable is not an array), the returned value will be NULL
.
Let's try out the following example to understand how this method works:
<?php
$hobbies = array("Acting", "Drawing", "Music", "Films", "Photography");
// Deleting first array item
$removed = array_shift($hobbies);
print_r($hobbies);
echo "<br>";
var_dump($removed);
?>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to convert URL to array in PHP
An URL is the string of many data. URL c...Laravel 8 Roles and Permissions Tutorial Part 2
In the previous tutorial article, we hav...Show Image Preview Before Upload In jQuery Bootstrap Example
Today, Laravelcode share one helpfull tu...Disable Text Selection In WebPage Using jQuery and CSS
Many times you need to prevent text sele...Laravel orderBy on Eloquent Relationships example
Laravel eloquent relationships provides...