update page now
Longhorn PHP 2026 - Call For Papers

Voting

: six plus three?
(Example: nine)

The Note You're Voting On

wes at nospam dot example dot org
7 years ago
Correct polyfill (one that doesn't make copies of arrays, and that doesn't make use of the IAP) is:

<?php

if(!function_exists('array_key_first')){
    function array_key_first(array $array){
        if($array === []){
            return NULL;
        }
        foreach($array as $key => $_) return $key;
    }
}

if(!function_exists('array_key_last')){
    function array_key_last(array $array){
        if($array === []){
            return NULL;
        }
        return array_key_first(array_slice($array, -1));
    }
}

?>

<< Back to user notes page

To Top