Re: array search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



probably missing something but php have a function called array_search.

Ben

On Sun, 23 Jan 2005 11:33:16 -0500 (EST), john@xxxxxxxxxxxxxxxxx
<john@xxxxxxxxxxxxxxxxx> 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)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux