parsing ip address in php

Posted by Ryan on Stack Overflow See other posts from Stack Overflow or by Ryan
Published on 2011-02-03T07:22:51Z Indexed on 2011/02/03 7:25 UTC
Read the original article Hit count: 259

Filed under:
|
|

Hi all, I am trying to create a page that shows the user their zip code when they are on my page.

(if any of you are familiar with GeoIP data, thats what I am using. )

I have a conversion that converts the users IP address into an IP number, that conversion is:

ipnum = 16777216*w + 65536*x + 256*y + z

where w.x.y.z are the ip sections (000.000.000.000)

My question is, using

$_SERVER['REMOTE_ADDR'];

is there a way for me to section the users ip address and assign the section of the ip address to variables?

for example:

usersip = 192.168.123.5

w = 192; x = 168; y = 123; z = 5;

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about ip