Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last()
| From: | Woortmann, Enno | Date: | Wed, 20 Jun 2018 09:17:39 +0000 |
| Subject: | Re: [RFC][Under Discussion] Add functions array_key_first()and array_key_last() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102317@lists.php.net to get a copy of this message | ||
Hi Levi,
Am 20.06.2018 um 04:47 schrieb Levi Morrison:
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); Ennolist($key, $value) = array_first($input); // $key will be null if the call failedlist($key, $value) = array_last($input); // $key will be null if the call failed