Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_key_first

Description

Gets the first key of an array

Syntax

array_key_first(array $array): int|string|null

Parameters

array

An array.

Return

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

Examples

1

<?

$array = array("a", "b", "c");

$return = array_key_first($array);

var_export($return);

?>
0

2

<?

$array = array("key1" => "a", "key2" => "b", "key3" => "c");

$return = array_key_first($array);

var_export($return);

?>
'key1'

3

<?

$array = array();

$return = array_key_first($array);

var_export($return);

?>
NULL
HomeMenu