Re: array search

From: Date: Sun, 23 Jan 2005 17:25:25 +0000
Subject: Re: array search
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-207090@lists.php.net to get a copy of this message
probably missing something but php have a function called array_search. Ben On Sun, 23 Jan 2005 11:33:16 -0500 (EST), john@johnallsopp.co.uk <john@johnallsopp.co.uk> wrote: > > I've been trying for days now to make this work. > > This worked for me (with my IP address for 'John'): > > <?php > $viz_ip= $_SERVER['REMOTE_ADDR']; > echo ("Your IP is $viz_ip"); > > $byte_ip= array( > > "204.126.202.56"=>"Mark", > > "63.230.76.166"=>"Bob", > > "84.196.101.86"=>"John", > ); > > function _array_search ($viz_ip, $byte_ip) { > > foreach($byte_ip as $key => $val) { > > if ($viz_ip === $key) { > return($val); > } > > } > > return(False); > } > > > ?> > > <p>Hi <?php echo (_array_search($viz_ip, $byte_ip)); ?></p> > > J > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct)

« previous php.general (#207090) next »