Re: [discussion] add array_usearch()
Hi all,
On Fri, Feb 7, 2014 at 9:26 AM, Tjerk Meesters <[email protected]>wrote:
> I'm not wildly enthusiastic about another magic flags parameter, but it's
> an acceptable compromise for me. The slight advantage there is that
> in_array()
would be bestowed upon the ability to take a callback function
> as well. Something like:
>
> if (in_array('is_numeric', $array, SEARCH_NEEDLE_IS_CALLBACK)) { ... }
>
What we need is 'closure only callback'.
If we have it, then we don't have to worry about string callback functions.
if (in_array(function($elem) {return is_numeric(strstr($elem));}, $array))
{ ... }
Why don't we have 'closure' as signature? It can do more than calling
a function.
bool in_array(closure $callback, array $ary);
Cons would be we cannot search closures in $ary.
Is there any use of searching closure?
Regards,
--
Yasuo Ohgaki
[email protected]
Thread (11 messages)