← All built-ins / array_key_first()

array_key_first()

array_key_first(...$args): mixed

Parameters

NameTypeDescription
$aarrayinput array

Return value

The first key, or null when empty.

Example

echo array_key_first(["a" => 1, "b" => 2]), "
";
echo array_key_first([]) == null ? "null" : "?", "
";
a
null

See also

array_key_last()reset()