ip2long

int ip2long(string ip_address) 

Converts a dotted-quad address into a decimal, IPv4 network address.

Returns:

Signed integer

Description:

ip2long() converts a dotted-quad format IP address (xxx.xxx.xxx.xxx) to a decimal, IPv4 network address. Add pow(2,32) (4,294,967,296) to “unsign” the value.

Availability:

UNIX, Windows

Version:

4.0b4+

See also:

long2ip() 

Example:

23.13. Convert an IP address from one format to another
$IP = '63.69.110.220'; 
// We add 2^32 (4,294,967,296) to unsign the value 
echo "The dotted-quad format IP address $IP is equivalent to ", 
     ip2long ($IP) + pow(2,32); 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.