Re: [discussion] add array_usearch()
| From: | Yasuo Ohgaki | Date: | Fri, 07 Feb 2014 06:36:34 +0000 |
| Subject: | Re: [discussion] add array_usearch() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72362@lists.php.net to get a copy of this message | ||
Hi all,
On Fri, Feb 7, 2014 at 9:26 AM, Tjerk Meesters <tjerk.meesters@gmail.com>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
yohgaki@ohgaki.net