Need help with maxmind geo ip php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    Need help with maxmind geo ip php script

    I am really new to php and trying to figure this out so I can get better results for whatstheirip.com. I need to convert every IP address to an IP number to use the GeoIp script from maxmind. Here is their formula to convert it:

    ipnum = 16777216*w + 65536*x + 256*y + z
    where
    IP Address = w.x.y.z

    So basically I need to convert an ip (lets use 24.24.24.24 as an example) to 4 different variables = w, x, y, z

    How do I do this?

    Ip address = $ip
  • Zoxxa
    Confirmed User
    • Feb 2011
    • 1026

    #2
    Sorry I am on my phone so can't give examples but you can use the explode function to accomplish this. Use the period as the delimiter, convert to array, echo each piece however you want.

    http://php.net/manual/en/function.explode.php
    [email protected]
    ICQ: 269486444
    ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!

    Comment

    • shake
      frc
      • Jul 2003
      • 4663

      #3
      Originally posted by Zoxxa
      Sorry I am on my phone so can't give examples but you can use the explode function to accomplish this. Use the period as the delimiter, convert to array, echo each piece however you want.

      http://php.net/manual/en/function.explode.php
      That should do it, the parts of an IP are the Octets, so you can feed each one in that way and you'll be good to go
      Crazy fast VPS for $10 a month. Try with $20 free credit

      Comment

      • mkx
        Confirmed User
        • Nov 2003
        • 4001

        #4
        cool that was easier than I thought, thanks guys

        Comment

        Working...