note 35252 added to function.in-array
| From: | danielr26 at charter dot net | Date: | Mon, 25 Aug 2003 17:46:10 +0000 |
| Subject: | note 35252 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55047@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35252
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35252&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35252&report=yes