Hi Levi,

Am 20.06.2018 um 04:47 schrieb Levi Morrison:
     list($key, $value) = array_first($input);
     // $key will be null if the call failed

     list($key, $value) = array_last($input);
     // $key will be null if the call failed

Your proposed functions would be implementable with the internal functions but I think this approach doesn't provide a clean function interface as it forces the user to evaluate the wanted value from the returned array structure by using either the list() construct or something like $key = array_first($input)[0];

I believe two functions with this interface will be confusing and less intuitive for the developer. If I use a function I expect it to give me a return value which I can use without any further post processing $wantedValue = fancyFunction($someInput);

Enno

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to