note 55571 deleted from function.key by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 08 Aug 2005 07:37:55 +0000 |
| Subject: | note 55571 deleted from function.key by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93224@lists.php.net to get a copy of this message | ||
Note Submitter:
----
A better key_in_array():
<?php
function key_in_array($needle, $haystack)
{
return in_array($needle, array_flip($haystack));
}
?>
(Note that even when you want to convert something to a boolean (if it isn't already), then
!!$something is better than $something?true:false and much better than a long if construct with
explicit returns, IMHO)