array search
| From: | Malcolm | Date: | Sun, 23 Jan 2005 15:59:11 +0000 |
| Subject: | array search | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-207086@lists.php.net to get a copy of this message | ||
Hello All,
I've been trying for days now to make this work.
I'm trying to search my array for a value and return the key.
I get the visitor's IP and try this -- this is the latest,
I've tried a few functions to echo the name associated with the viz_ip.
$viz_ip= $_SERVER['REMOTE_ADDR'];
$byte_ip= array(
"204.126.202.56"=>"Mark",
"63.230.76.166"=>"Bob",
"63.220.76.165"=>"John",
);
function _array_search ($viz_ip, $byte_ip) {
foreach($byte_ip as $key => $val) {
if ($viz_ip === $key) {
return($val);
}
}
return(False);
}
I'm no wiz but this shouldn't be this hard, maybe I'm thinking wrong.
I've read the examples at php.net but I just can't get it. Some help
or even a hint ?
best regards,
malcolm
--
Ommmm