note 90839 added to function.array-key-exists
| From: | s dot nerz at nospam dot orestes-sol dot com | Date: | Tue, 12 May 2009 14:38:51 +0000 |
| Subject: | note 90839 added to function.array-key-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154505@lists.php.net to get a copy of this message | ||
@Gibson: Your array_key_exists will return a *false* value for some cases, where the array key
actually exists...
<?php
$foo = array('key' => FALSE);
if ( array_key_exists_nc('key', $foo) ) {
print "Key exists!";
} else {
print "Key does NOT exist!";
}
?>
will print "Key does NOT exist!" .. This is one of the fundamental differences between
isset and array_key_exists - and thus should (perhaps) not be changed ...
----
Server IP: 212.124.37.9
Probable Submitter: 80.153.14.168
----
Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php
Edit -- https://master.php.net/note/edit/90839
Del: integrated -- https://master.php.net/note/delete/90839/integrated
Del: useless -- https://master.php.net/note/delete/90839/useless
Del: bad code -- https://master.php.net/note/delete/90839/bad+code
Del: spam -- https://master.php.net/note/delete/90839/spam
Del: non-english -- https://master.php.net/note/delete/90839/non-english
Del: in docs -- https://master.php.net/note/delete/90839/in+docs
Del: other reasons-- https://master.php.net/note/delete/90839
Reject -- https://master.php.net/note/reject/90839
Search -- https://master.php.net/manage/user-notes.php