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

ip, php, range

Solution

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";
}

Problem

I have an IP address and I'm given two other IP addresses which together creates an IP range. I want to check if the first IP address is within this range. How can i find that out in PHP?

Original source

Related problems