//(PHP 7 >= 7.3.0)
$key = array_key_last($data);
//ALL PHP Versions
end($data); // move the internal pointer to the end of the array
$key = key($data); // fetches the key of the element pointed to by the internal pointer
<?php
$source_array = ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'];
$result = end($source_array);
echo "Last element: ".$result;
?>
<?php
$source_array = [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
];
echo "Last index: " . array_key_last($source_array);
?>
end($arr)
echo end(['Gon', 'Killua', 'Hisoka']) // print Hisoka
end(array[]);
array_slice($a, -3, 3, true);