1

I'm trying to get user city using ipaddress and for that I have found this https://lite.ip2location.com/database-ip-country-region-city

In the instruction is says "translate the IP address to an IP number in decimal format" but I don't know how .

This is my ip address : 5.219.212.240 , What should I do according to the instruction?

Thanks

j edgar
  • 149
  • 1
  • 10

1 Answers1

2

Well I think this is what documentation refers to. Here is an example from the link:

Calculating the decimal value of an IPv4 address is easy. If we were to number the octets from left to right and break them into variables called $octet1, $octet2, $octet3 and $octet4, we can use the following formulas to convert each octet into its decimal value and then add each decimal value to achieve the decimal equivalent for the IP address:

$octet1 x (256^3) = $decimal1

$octet2 x (256^2) = $decimal2

$octet3 x (256) = $decimal3

$octet4 = $decimal4

$decimal1 + $decimal2 + $decimal3 + $decimal4 = $decimal_equivalent

For example, converting IP Address 192.168.1.16 to its decimal equivalent would look like this:

192 x (256^3) = 3221225472

168 x (256^2) = 11010048

1 x 256 = 256

16 = 16

3221225472 + 11010048 + 16 = 3232235792

The decimal equivalent of 192.168.1.16 is 3232235792.

fsacer
  • 1,382
  • 1
  • 15
  • 23