Re: array search

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

 



> 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


[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