note 83500 deleted from function.array-key-exists by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 20:46:58 +0000 |
| Subject: | note 83500 deleted from function.array-key-exists by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218776@lists.php.net to get a copy of this message | ||
Note Submitter: mankyd at gmail dot com
----
You'll notice several notes on this page stating that isset() is significantly faster than
array_key_exists(). This may be true except for one small hitch. isset() will return false for
arrays keys that have there value set to NULL, which is therefore not entirely accurate.
Example:
<?php
$foo = array();
$foo['bar'] = NULL;
var_dump(isset($foo['bar']));
var_dump(array_key_exists('bar', $foo));
?>
will output:
bool(false)
bool(true)
Be aware of this!