protected function isIpInRange($targetIp, $rangeIp, $cidrMask)
    {
        $target = sprintf('%032b', ip2long($targetIp));
        $range = sprintf('%032b', ip2long($rangeIp));

        return 0 === substr_compare($target, $range, 0, $cidrMask);
    }
protected function isIpInRange($targetIp, $rangeIp, $cidrMask)
    {
        $target = sprintf('%032b', ip2long($targetIp));
        $range = sprintf('%032b', ip2long($rangeIp));

        return 0 === substr_compare($target, $range, 0, $cidrMask);
    }
protected function isIpInRange ( $ targetIp , $ rangeIp , $ cidrMask ) { $ target = sprintf ( '%032b' , ip2long ( $ targetIp ) ) ; $ range = sprintf ( '%032b' , ip2long ( $ rangeIp ) ) ; return 0 === substr_compare ( $ target , $ range , 0 , $ cidrMask ) ; }
Determines if a target IP address is within a particular IP address range.

@param string $targetIp The IP address to check
@param string $rangeIp  The IP address defining the range
@param int    $cidrMask The CIDR notation net mask defining the range

@return bool True if the target IP falls within the specified range. Otherwise false.
Determines if a target IP address is within a particular IP address range .