by @CodingExample

How to get first element of an array in PHP

Home » php » How to get first element of an array in PHP

To get the first element of an array we need to use the built-in reset() function in PHP.

$arr = array("lion", "tiger", "cat");

echo reset($arr); // lion

reset() -> rewinds array’s internal pointer to the first element and returns the value of the first array element.