Conversion tables A-K
  Conversion tables L-Z
  SPAM database query
  Reverse WHOIS utility
  North America area codes
  PHP Example forums

PHP example repository.

Web www.web-max.ca
Back to examples
Converts an IP address from a string to a positive integer.

Take an IP address in xxx.xxx.xxx.xxx format and converts it to an integer value. The addition in this routine makes sure the returned number is a positive value, which allows for easier handling of comparisions on the integer value if the original IP is greater than 127.255.255.255.

<?php
    
// We will user the remote IP for this example

    
$ip2 ip2long($REMOTE_ADDR);

    if (
$ip2 0$ip2 += pow(2,32); 

    print(
$ip);

?>
 
Example