note 53727 added to function.array-key-exists

From: Date: Fri, 10 Jun 2005 19:19:37 +0000
Subject: note 53727 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-90235@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53727 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53727&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53727&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53727&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53727&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53727&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53727&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90235) next »