PHP array_key_last() Function
The array_key_last() is an inbuilt function of PHP and is used to gets the last key of an array.
You can get the last key from given array without affecting the internal array pointer.
You can get the last key from given array without affecting the internal array pointer.
Syntax:
array_key_last(array)
Parameters:
array:
An array.
Returns the last key of
array
if the array is not empty; NULL
otherwise.
Simple Example:
<?php
$array = ['apple' => 1, 'banana' => 2, 'mango' => 3];
$lst= array_key_last($array);
var_dump($lst);
?>
Output:
string(5) "mango"
Leave a Comment