Since reset() and end() return false when the array is empty, in a sense, there is an idea that there is no need to take such strict care of the return value.
If you were to take proper care, you would probably specify a default value or throw an exception, as has already been suggested. However, specifying a default value is not very smart in my opinion. The fact that what value is considered to be "unable to obtain" changes depending on the situation causes some complexity. And when dealing with an array whose values are completely unknown, it becomes necessary to "hope" that the values do not conflict with the default values. Can the following signature meet your requirements? Or will it become too complicated? ``` // arrar_first(array $arr, bool &$has_value) $value = array_first($arr, $has_value); if ($has_value) { // array has items // $value is mixed } else { // array is empty // $value === null } ``` Regards. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php