note 64506 deleted from function.array-key-exists by nlopess
| From: | nlopess@php.net | Date: | Mon, 17 Apr 2006 10:09:53 +0000 |
| Subject: | note 64506 deleted from function.array-key-exists by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108305@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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.