PPS
PPS

Reputation: 552

Find the value in an array one by one

We would like to know, how can we check the value in array one bye one ... Let me explain you.

want to check the C class ip's into an array, is there any easy function to check the whole thing..

Thanks Rod.

Upvotes: 0

Views: 98

Answers (1)

dog
dog

Reputation: 410

Sorry, I do not understand your question. If you are asking whether an IP adress is in the 192.168.0.0/16 range:

$ip = ip2long("192.168.5.7");
$mask = ip2long("192.168.0.0");
if(($ip & $mask) == $mask) 
  echo "Is in 192.168.0.0/16";
else
  echo "Not in range";

Upvotes: 2

Related Questions