How to check an IP address is within a range of two IPs in PHP?

With ip2long() it’s easy to convert your addresses to numbers. After this, you just have to check if the number is in range:

if ($ip <= $high_ip && $low_ip <= $ip) {
  echo "in range";
}

Leave a Comment