> This function signature can be accomplished by userland once we have > `array_key_first()` and `array_first()`. It's much better to keep > `array_first()` as simple as possible and let everyone build their own > approach to go about it since we have so many approaches.
The goal wasn't necessarily to keep them together. The goal was to introduce an arguably simple way to: 1. Be able to get the first/last value of an array. 2. Know if the value was actually in existence or not, rather than just blindly returning null when it could be a valid value. 3. Accompany multiple use cases like needing to return a default if not found or throwing an exception. 4. Offer a way to know if the value existed or not and act accordingly without additional logic checking the key. 5. Address the seeming genericness of the function name. * If I were someone who seen the name for the first time. I'd see it and ask array_first what? And proceed to the docs. The different approaches are trying to figure out the best way to know whether the result was the actual value from the array or some baked in language default null. I get your desire to keep things simple, but IMO returning a value that does not conflict with possibly valid values or somehow indicates the value was not present is important, and should come before simplicity. Which likely means involving the key somehow. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php