note 49015 deleted from function.array-key-exists by bjori
| From: | bjori@php.net | Date: | Mon, 01 May 2006 22:30:07 +0000 |
| Subject: | note 49015 deleted from function.array-key-exists by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110308@lists.php.net to get a copy of this message | ||
Note Submitter: exaton at NOSPAM dot free dot fr
----
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...