Menu Home

array_key_first

osbo.com | PHP | Functions | array_key_first

Gets the first key of an array

Syntax

array_key_first ( array $array ) : mixed

Parameters

array

An array.

Return

Returns the first key of array if the array is not empty; NULL otherwise.

Examples

<?

$array = array("a" => 0, "b" => 1, "c" => 2);

$return = array_key_first($array);

var_dump($return);

?>
string(1) "a"

PHP