Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7068 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71264 invoked by uid 1010); 13 Jan 2004 21:45:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 71240 invoked from network); 13 Jan 2004 21:45:35 -0000 Received: from unknown (HELO stella.fastforwardnetwork.com) (209.51.153.50) by pb1.pair.com with SMTP; 13 Jan 2004 21:45:35 -0000 Received: (qmail 15311 invoked from network); 13 Jan 2004 22:50:01 -0000 Received: from p508aa864.dip.t-dialin.net (HELO hristov.com) (80.138.168.100) by d.goto.bg with SMTP; 13 Jan 2004 22:50:01 -0000 Message-ID: <400466AB.2020502@hristov.com> Date: Tue, 13 Jan 2004 22:44:11 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20031230 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christian Schneider CC: internals@lists.php.net References: <40045BB4.4050000@hristov.com> <40046198.6010800@cschneid.com> In-Reply-To: <40046198.6010800@cschneid.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: new function? From: php@hristov.com (Andrey Hristov) Hi Christian, Christian Schneider wrote: > Andrey Hristov wrote: > >> It works like in_array() but checks whether all needles >> are in the stack array. > > > Looking at the prototype: > bool in_array_all(mixed needle1[, mixed needle2], mixed haystack [, bool > strict]) > > I'd say if (and I'm personally -1) this is added it should be > > bool in_array_all(array needles, array haystack [, bool strict]) > > IMHO which would make parameter handling much simpler. > > But then again you could also do array_intersect($needles, $haystack) to > get the same result in a lot of cases. > > - Chris > So, I did now some testing. Looks like in_array_all() is 6x faster than array_intersect() the haystack is 10 elements, and needles are 3. When 1000 elements in haystack, the fastest time (when the needles are in the beggining in_array_all is 300x faster. When the whole haystack should be traversed it's about 250x faster than array_intersect. When one of the needles is not in the haystack : 300x . Script : andrey@poohie:~/dev/5_0> ./php s.php bool(true) Time : 0.00010 array(0) { } Time : 0.03888 Andrey