superglobal needed

Discussion in 'PHP' started by PoohBear88, Oct 17, 2007.

  1. #1
    I'm a php noob.

    Is there a superglobal that tells which keywords the visitors that came from search engines are?

    Say a visitor searches for "apples" on google, how can i implement that keyword using php?
     
    PoohBear88, Oct 17, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    if (preg_match('~[&\?]q(?:uery)?=([^&]+)~', $_SERVER['HTTP_REFERER'], $keywords))
    {
        echo $keywords[1];
    }
    
    
    PHP:
    This should do it... it's untested though.
     
    nico_swd, Oct 18, 2007 IP