note 53727 deleted from function.array-key-exists by bjori

From: Date: Mon, 01 May 2006 22:30:38 +0000
Subject: note 53727 deleted from function.array-key-exists by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-110311@lists.php.net to get a copy of this message
Note Submitter: Tim Behrendsen ---- Not sure about the test program above, but array_key_exists is not *that* much slower (although it is definitely slower). My (simpler) test using php 4.3.10: <?php $test = $argv[1]; $a = range(1, 5000); if ($test == 0) { for ($i = 0; $i < 1000000; ++$i) { $foo = array_key_exists(333, $a); } } if ($test == 1) { for ($i = 0; $i < 1000000; ++$i) { $foo = $a[333] == null; } } if ($test == 2) { for ($i = 0; $i < 1000000; ++$i) { $foo = isset($a[333]); } } ?> Results: $ time php /tmp/junk.php 0 real 0m2.739s user 0m2.707s sys 0m0.010s $ time php /tmp/junk.php 1 real 0m2.184s user 0m2.156s sys 0m0.013s $ time php /tmp/junk.php 2 real 0m1.761s user 0m1.700s sys 0m0.007s So yeah, it's slower, but unless you're doing millions of loops, you're probably not going to notice the difference. The above post is definitely misleading.

« previous php.notes (#110311) next »