note 108792 added to function.array-key-exists
| From: | gregs at net-virtual dot com | Date: | Fri, 25 May 2012 00:30:14 +0000 |
| Subject: | note 108792 added to function.array-key-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188213@lists.php.net to get a copy of this message | ||
I am confused by comments stating that array_key_exists is fast, or maybe 1.5x slower then isset:
bash$: php -v
PHP 5.3.5 (cli) (built: Jan 23 2012 11:13:00)
bash$ time php -r '$array =array("foo" => "bar");for($i = 0; $i <
10000000; $i++) { array_key_exists("foo", $array);array_key_exists("bar",
$array);}'
real 0m20.036s
bash$ time php -r '$array =array("foo" => "bar");for($i = 0; $i <
10000000; $i++) { isset($array["foo"]);isset($array["bar"]);}'
real 0m2.553s
bash$ uname -opisr
Linux 2.6.18-194.3.1.el5 x86_64 x86_64 GNU/Linux
----
Server IP: 69.147.83.197
Probable Submitter: 64.124.74.4
----
Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php
Edit -- https://master.php.net/note/edit/108792
Del: integrated -- https://master.php.net/note/delete/108792/integrated
Del: useless -- https://master.php.net/note/delete/108792/useless
Del: bad code -- https://master.php.net/note/delete/108792/bad+code
Del: spam -- https://master.php.net/note/delete/108792/spam
Del: non-english -- https://master.php.net/note/delete/108792/non-english
Del: in docs -- https://master.php.net/note/delete/108792/in+docs
Del: other reasons-- https://master.php.net/note/delete/108792
Reject -- https://master.php.net/note/reject/108792
Search -- https://master.php.net/manage/user-notes.php