source/NetworkComponentsByDanielGP.php
public function convertIpToNumber($ipGiven)
    {
        if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
            if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                $ips = explode('.', $ipGiven);
                return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216;
            } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
                return $this->convertIpV6ToNumber($ipGiven);
            }
        }
        return 'invalid IP';
    }
public function convertIpToNumber($ipGiven)
    {
        if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
            if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                $ips = explode('.', $ipGiven);
                return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216;
            } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
                return $this->convertIpV6ToNumber($ipGiven);
            }
        }
        return 'invalid IP';
    }
public function convertIpToNumber ( $ ipGiven ) { if ( filter_var ( $ ipGiven , FILTER_VALIDATE_IP ) ) { if ( filter_var ( $ ipGiven , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { $ ips = explode ( '.' , $ ipGiven ) ; return $ ips [ 3 ] + $ ips [ 2 ] * 256 + $ ips [ 1 ] * 65536 + $ ips [ 0 ] * 16777216 ; } elseif ( filter_var ( $ ipGiven , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) { return $ this -> convertIpV6ToNumber ( $ ipGiven ) ; } } return 'invalid IP' ; }
Converts IP to a number

@param type $ipGiven
@return string|int
Converts IP to a number