Before few days we have a requirement to remove an element from php array.
To fulfill our requirement we have used php functions.
There are three functions which can be useful to delete an element from php array.
“array_shift(array)” removes first element from an array.
“array_pop(array)” removes last element from an array.
“array_splice(array,start,length,array)” removes selected elements from an array and replaces it with new elements.
Follow the under given example to check it practically.
$array = array("first", "second", "third", "fourth", "fifth", "sixth"); array_shift($array); array_pop($array); array_splice($array, 0, 2); print_r($array);
Hope this will help you.