Easy Tutorial
❮ Func Array Merge Recursive Func Array ❯

PHP array_key_last() Function

Complete PHP Array Reference Manual

Example

Get the last key of an array:

<?php
$array = ['a' => 1, 'b' => 2, 'c' => 3];

$lastKey = array_key_last($array);

echo $lastKey;
?>

Executing the above code will output:

c

Definition and Usage

The array_key_last() function gets the last key of an array.


Syntax

array_key_last ( array $array ) : mixed
Parameter Description
array The array to operate on.

Technical Details

Return Value: Returns the last key of the array (if not empty), otherwise returns null.
PHP Version: PHP 7 >= 7.3.0, PHP 8
--- ---

Complete PHP Array Reference Manual

❮ Func Array Merge Recursive Func Array ❯