Re: Function boolval()
| From: | Sebastian Krebs | Date: | Sat, 28 Apr 2012 18:11:48 +0000 |
| Subject: | Re: Function boolval() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60352@lists.php.net to get a copy of this message | ||
Am 28.04.2012 06:27, schrieb Kalle Sommer Nielsen:
Hi 2012/4/27 Jille Timmermans<jille@quis.cx>:$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...Hi, I suggest we add a function boolval(). It simply converts the given argument to a boolean, like strval(), intval() and floatval(). I already have an implementation ready[1]. Why? * It is missing in the current list of *val()-functions and people expect it to exist. I'd say it is an inconsistency. * It can be used as a callback, which is why a bool-cast does not suffice.Does it really matter nowadays when we got closures anyway: $bools = array_map(range('a', 'z'), function($a){ return((boolean) $a); });