note 35252 deleted from function.in-array by didou
| From: | didou@php.net | Date: | Thu, 16 Oct 2003 11:19:42 +0000 |
| Subject: | note 35252 deleted from function.in-array by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58688@lists.php.net to get a copy of this message | ||
Note Submitter: danielr26@charter.net
----
[editor note : you can also use array_keys()
didou]
To search thru the keys instead of the values, use the built-in function "array_flip"
instead of writing your own code.
Example (untested):
<?php
$var = array (
"Bob" => "Jones",
"Silvia" => "Allen",
"Stupid" => "Head"
);
$var = array_flip ($var);
$result = in_array("Bob", $var, TRUE);
?>
$result should be TRUE