That makes perfect sense to me as I see/use this sort of code in JavaScript.
Well, PHP is not Javascript - and BTW Javascript is a complex language and I don't think we should import that complexity into PHP.
The argument about making the filter a global function is not sensible
to apply in all circumstances. In many cases the filter is only going
to be of use in an array_filter() call, so now we would have 2
functions to do the work of 1.
No, we won't - both cases have only one function, if you don't count array_filter(), and two, if you do.
Maybe a syntax like this would be more appealing ...
array_filter($my_data as $test) {
return 4 === ($test % 4);
}
No, it won't be. If you are looking for Scheme or Ruby, you know where to find it :)
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com