1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

using string functions

Discussion in 'PHP' started by sudhakararaog, Jul 14, 2008.

  1. #1
    i am using $ip= $_SERVER['REMOTE_ADDR'] to retrieve the ip address of the client for example if the value returned from $ip

    is 50.160.190.150

    i would like to find out which country the request has come from. i believe by using the third set of numbers (in this case=190) from an ip address we can find out the country name. i can declare a variable with a list of country names and the range of values, what i need help is to extract the 3rd set of numbers from $ip.
    SEMrush
    as ip address keep changing the 3rd set of numbers can be single, double or
    3 digit number how can we extract the number that is stored in $ip after the second dot and before the third dot

    please advice.

    thanks.
     
    sudhakararaog, Jul 14, 2008 IP
    SEMrush
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,731
    Likes Received:
    26
    Best Answers:
    13
    Trophy Points:
    175
    #2
    EricBruggema, Jul 14, 2008 IP