php show content basdon country location

Discussion in 'PHP' started by saturn100, Apr 24, 2011.

  1. #1
    Hi
    anyone know how to do this
    I am looking to change text on my website based on what location the visitor is in so for example is visitor is from US says Click here if from germany Hier Klick

    Thanks
     
    saturn100, Apr 24, 2011 IP
  2. littlejohn199

    littlejohn199 Peon

    Messages:
    42
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use php ip 2 country code to do that.
    http://code.google.com/p/php-ip-2-country/


    From the sample code of that link, you can do this

    if(strtolower($phpIp2Country['COUNTRY']) == 'us')
    {
    //show content for us visistors
    }
    elseif(strtolower($phpIp2Country['COUNTRY']) == 'germany')
    {
    //show content for german visistors
    }
    else
    {
    //show something else.
    }

    Little John
     
    littlejohn199, Apr 25, 2011 IP