note 108792 rejected from function.array-key-exists by danbrown

From: Date: Fri, 25 May 2012 15:22:28 +0000
Subject: note 108792 rejected from function.array-key-exists by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188236@lists.php.net to get a copy of this message
Note Submitter: gregs at net-virtual dot com ---- 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

« previous php.notes (#188236) next »