Re: Re: new function?

From: Date: Tue, 13 Jan 2004 22:04:11 +0000
Subject: Re: Re: new function?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-7071@lists.php.net to get a copy of this message
Hi Andrei :) Andrei Zmievski wrote:
On Tue, 13 Jan 2004, Andrey Hristov wrote:
Hi, just a correction, I meant array_diff when i wrote array_intersect. array_diff is more handy since just count($res)==0 is enough, $res is the returned array of array_diff().
Did you actually try array_intersect()? - Andrei Here it is :
andrey@poohie:~/dev/5_0> cat s2.php <?php $i = 0; while ($i++ < 1000) {
        $a[] = $i;
} $start = microtime(1); $res = in_array_all(100, 2, 3, $a, true); $end = microtime(1); var_dump($res); printf("Time : %3.5f\n",$end - $start); $needles = array(100, 2, 3); $start = microtime(1); $diff = array_intersect($needles, $a); $end = microtime(1); var_dump($diff); printf("Time : %3.5f\n",$end - $start); ?>andrey@poohie:~/dev/5_0> ./php s2.php bool(true) Time : 0.00010 array(3) { [0]=> int(100) [1]=> int(2) [2]=> int(3) } Time : 0.03078 About 300x . Andrey

« previous php.internals (#7071) next »