PHP array_key_first() Function

The array_key_first() function returns the first key of an array without affecting its internal pointer.

Key Features of array_key_first()

Syntax of array_key_first()

Syntax

mixed array_key_first(array $array);

Example Using array_key_first()

The following example demonstrates how array_key_first() is used:

Example


$array = ["a" => "PHP", "b" => "JavaScript", "c" => "Python"];
            
$firstKey = array_key_first($array);
echo "The first key is: " . $firstKey;

Output

The first key is: a