Hello
I have an array with of server ip with server name like this
$ips = array(
"12.12.12.12" => "server1",
"12.12.12.13" => "server2",
"12.12.12.14"=> "server3"
);
I am trying to write the code to check if a $newip exists on the $ips array
and if exists I wish to show the server name for that ip.
How to do that please ?
For example if $newip = 12.12.12.13 since it exists on $ips , the code should return "server2".
I am trying
<?
$ips = array(
"12.12.12.12" => "server1",
"12.12.12.13" => "server2",
"12.12.12.14"=> "server3"
);
$newip="12.12.12.13";
if (in_array($newip, $ips ))
{
echo "exists $ips[$newip]";
}
else
{
echo "not exists";
}
?>
but it does not work , I always receive "not exists";
Any help please ?
Thanks