note 49015 added to function.array-key-exists

From: Date: Fri, 14 Jan 2005 13:55:42 +0000
Subject: note 49015 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-83268@lists.php.net to get a copy of this message
I am also noting performance gain by using isset() instead of array_key_exists(). Rudimentary tests (involving the construction of a big random array, then long testing loops working out average times) have shown a consistent 30 to 35% gain in favor of isset(), whether working with integer or string array keys, and whether the result is true or false. The test arrays indeed did not hold any NULL values, however, and I understand that is where the issue is. It would seem therefore, that if an array is practically certain not to contain NULL values, or if that fact is irrelevant, then it is preferable to stick with isset(). I find that most counter-intuitive ; some months ago I switched my practice to array_key_exists() thinking I was doing the smart thing by using a more "dedicated" function... ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49015 Delete -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+49015&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+49015&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83268) next »