> There is also a technique to make the return value `[$key => $value]` instead > of just a value, but this loses simplicity.
Hmm, since the naming array_first and array_last doesn't clarify that it's returning a key or a value. What if it returned both as ?[key, value]. That opens quite a few use possibilities: $first = array_first($array); $value = $first[1] ?? throw new Exception(); [,$value] = array_first($array) ?? [null, null]; [,$value] = array_first($array) ?? throw new Exception(); -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php