note 44355 deleted from function.array-key-exists by aidan
| From: | aidan@php.net | Date: | Wed, 04 Aug 2004 08:14:11 +0000 |
| Subject: | note 44355 deleted from function.array-key-exists by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73899@lists.php.net to get a copy of this message | ||
Note Submitter: e
----
isset() is not equivelent to array_key_exists(). isset() does not detect array keys that correspond
to a null value, while array_key_exists() does.
Proof:
<?php
$a = array('cat' => null);
if (array_key_exists('cat', $a)) {
print "array_key_exists() detects array keys whose value is null";
}
if (isset($a['cat'])) {
print " and so does isset()";
}
else {
print " but isset() doesn't";
}
?>
presents the output:
"array_key_exists detects array keys whose value is null but isset() doesn't"