The ip2long()
and long2ip()
functions should work just fine.
Note : you should use those for IPv4 addresses -- make sure that, in your case, $_SERVER['REMOTE_ADDR']
actually contains a valid IPv4 address (and not some IPv6-stuff).
Trying on a google IP address :
var_dump(ip2long('209.85.227.147'));
var_dump(long2ip(3512066963));
I get the following output :
int(3512066963)
string(14) "209.85.227.147"