In this tutorial, we are going to learn about how to get the first element of an array in PHP.
To get the first element of an array, we can use the built-in
reset() function in PHP.
Here is an example:
$arr=array("lion", "tiger", "cat"); $firstElement=reset($arr); echo $firstElement;
Note: The reset() function rewinds the array’s internal pointer to the first element and returns the value of it.