note 44355 added to function.array-key-exists
| From: | e at rn2 dot php dot net | Date: | Tue, 03 Aug 2004 16:31:15 +0000 |
| Subject: | note 44355 added to function.array-key-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73846@lists.php.net to get a copy of this message | ||
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"
----
Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44355
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44355&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44355&report=yes
Search -- http://master.php.net/manage/user-notes.php