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

array_key_last

Description

The array_key_last of Array for PHP gets the last key of an array.

Syntax

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

Parameters

array

An array.

Return

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

Examples

1

<?

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

$return = array_key_last($array);

var_export($return);

?>
2

2

<?

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

$return = array_key_last($array);

var_export($return);

?>
'key3'

3

<?

$array = array();

$return = array_key_last($array);

var_export($return);

?>
NULL
HomeMenu