As a complement of MySQL - IP To Numeric Value, here is how to convert IP to numeric value using PHP.
int ip2long ( string $ip_address )
printf(“%u\n”,?ip2long(“209.207.224.40″));?//return 3520061480.
To convert numeric value to IP:
string long2ip ( int $proper_address )
long2ip(3520061480);?//return 209.207.224.40
Because PHP’s integer type is signed, and many IP addresses will result in negative integers, you need to use the “%u” formatter of sprintf() or printf() to get the string representation of the unsigned IP address.
Be First To Comment
Related Post
Leave Your Comments Below