note 64506 added to function.array-key-exists
| From: | php-general at lists dot php dot net | Date: | Mon, 17 Apr 2006 05:29:52 +0000 |
| Subject: | note 64506 added to function.array-key-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108301@lists.php.net to get a copy of this message | ||
An optimization for cases where the key exists more often than not is to do the following:
<?php
if( isset( $foo['someKey'] ) || array_key_exists( $foo['someKey'] ) )
{
echo 'Yaaaaaaaaaaay!';
}
?>
This will only fall back on array_key_exists() when the value assigned is null or really
doesn't exist.
----
Server IP: 66.207.199.35
Probable Submitter: 66.11.173.122
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php
Edit -- http://master.php.net/note/edit/64506
Del: integrated -- http://master.php.net/note/delete/64506/integrated
Del: useless -- http://master.php.net/note/delete/64506/useless
Del: bad code -- http://master.php.net/note/delete/64506/bad+code
Del: spam -- http://master.php.net/note/delete/64506/spam
Del: non-english -- http://master.php.net/note/delete/64506/non-english
Del: in docs -- http://master.php.net/note/delete/64506/in+docs
Del: other reasons-- http://master.php.net/note/delete/64506
Reject -- http://master.php.net/note/reject/64506
Search -- http://master.php.net/manage/user-notes.php