array_shift(): Taking out first element of the array
Take out the first element of the array and returns the same. After applying array_shift() total elements of the array reduces by one. All numerical array keys are re-indexed but literal keys remain same.
Returns the shifted element ( first element ) of the array. Here $input is an array, $output get the value of first element of the array.
Output of above code is here( $output gets the first element One )
With Literal Keys
Output is here, ( $output gets the first element Banana)
Using currentBy using current() we can get the element to which the present internal pointer is pointing. By default it points to first element of the array.
Output is here.( The first element is changed from Banana to Mango)
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
|