> > $bools = array_map(function($a){ return((boolean) $a); }, range('a', 'z')); > $bools = array_map('boolval', range('a', 'z')); > > Second one seems more readable to me... > >
Sorry, I forget to hit reply-all sometimes... So lets try that again... Why is this going to be more beneficial to implement? Is it that you feel readability of the closure is too difficult or that you feel there is a use case that presents further benefits for implementing a boolval function, beyond that of just readability or other subjective preferences? Personally, I would feel something like array_filter(range('a','z')); is way more readable than all of the above and makes a lot more sense to me. Under most circumstances, one does not tend to care about the truth in expression unless it is truth. So the following code is far more practical than the suggestions being made here: if (!array_filter(array(0,false,null,'', array()))) { /* The array is made up entirely of falsey values */ } else { /* The array is not made up entirely of falsey values */ } I'm not saying the function is useless. I'm just saying PHP already offers more than 1,000 functions through core, alone, and adding just one more function that doesn't seem to offer anything new really isn't sounding like a promising idea to me. We only add to people's confusion more by offering them dozens of choices to accomplish the same thing. We've all heard the arguments of "print vs. echo", or X vs Y. There's no practical reason to include this in core being presented hear apart from "I like it more..." -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php