by @saigowthamr

How to get the first element key in a array PHP

Home » php » How to get the first element key in a array PHP

To get the first element key in a array we need to use the built-in array_key_first() function in PHP.

Here is an example:

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

echo array_key_first($arr); // 0

arraykeyfirst(): Get the first key of the given array without affecting the internal array pointer.


Best Web Development courses