PHP to convert IPv4 to Xenforo storable format


I am able to pull IP's out of the Xenforo database using
$iparray[] = long2ip(hexdec(bin2hex($row['ip'])));

I want to be able to store IP addresses using my API, this uses PHP and MYSQL queries.

How can I do the reverse of above to convert the IP to the correct format to store?

ip2long($ip) is incorrect and needs something further.
Top Bottom