Are you sure that the IP is stored using inet_pton
?
This is the result if we simply convert every 2 characters into decimal:
<?php
$ipPacked = '75f1382f';
$ipSegments = array();
for ($i = 0; $i < 8; $i += 2) {
$ipSegments[] = hexdec($ipPacked[$i] . $ipPacked[$i + 1]);
}
$ipReal = implode('.', $ipSegments);
var_dump($ipReal); //string(13) "117.241.56.47"
?>
Is that your correct IP?
If it is inet_pton
(which doesn't make sense as most of those are characters outside regular ASCII scopes) then you can simply use inet_ntop
to get it back.
To convert an IP into this hex format, you can do the following:
<?php
$ip = '117.241.56.47';
$ipSegments = explode('.', $ip);
$ipPacked = '';
for ($i = 0; $i < 4; $i++) {
$ipPacked .= sprintf("%02s", dechex((int)$ipSegments[$i]));
}
echo $ipPacked; //75f1382f
?>