Longman\IPTools\Ip::processWithMinus PHP Method

processWithMinus() protected static method

Checks if an IP is part of an IP range.
protected static processWithMinus ( string $range ) : boolean
$range string IP range specified in one of the following formats: Start-End IP format: 1.2.3.0-1.2.3.255 OR 2001:cdba:0000:0000:0000:0000:3257:0001-2001:cdba:0000:0000:0000:0000:3257:1000
return boolean true if IP is part of range, otherwise false.
    protected static function processWithMinus($range)
    {
        list($lower, $upper) = explode('-', $range, 2);
        $lower_dec = self::ip2long($lower);
        $upper_dec = self::ip2long($upper);
        $ip_dec = self::ip2long(self::$ip);
        return $ip_dec >= $lower_dec && $ip_dec <= $upper_dec;
    }