Try to beat this polyfill in terms of performance!
<?php
if( !function_exists('array_key_last') ) {
function array_key_last(array $array) {
if( !empty($array) ) return key(array_slice($array, -1, 1, true));
}
}
// Bonus
if (!function_exists('array_key_first')) {
function array_key_first(array $arr) {
foreach($arr as $key => $unused) return $key;
}
}
?>