Forum Moderators: coopster
I was hoping to use the http_referer data from the inbound url, and if it was from a search engine, use the terms that they input to provide alternative listings based on what currently exists in the database.
Theory
I've seen this done, so I know it can be, but now to figure out how.
This is the part where I break down.
What I think I need to do
I need to select the value in the array that contains the 'p=' or 'q=' (for example), and then trim off that bit and split the rest using '+'.
Thing is, I don't know how to select the value from the array, as it doesn't seem to always be in the same place... Any ideas?
$urlarray =
parse_url ("http://search.yahoo.com/search?
p=search+terms&ei=UTF-8&fr=fp-tab-web-
t&n=20&fl=0&x=wrt");
p=alicante+airport&ei=UTF-8&fr=fp-tab-web-t&n=20&fl=0&x=wrt
Array ( [0] => p=search+terms [1] => ei=UTF-8
[2] => fr=fp-tab-web-t [3] => n=20 [4] => fl=0 [5] =>
x=wrt )
That p=search+terms is what I need to get at.
take a look at the parse_str [php.net] function. here you go with ease:
parse_str($urlarray['query'],$urlqueryvars); you'll find the value of q in
$urlqueryvars['q'] then. hint: you often can get usefull tips quickly by using the online documentation on php.net. just use php.net/function-name and read the comments by others there.
- hakre
hint: you often can get usefull tips quickly by using the online documentation on php.net. just use php.net/function-name and read the comments by others there.
I do use this quite a bit, but my inexperience often gets me searching around for the right function - this and that there are always >1 way to do something sometimes gets me going in circles... or the wrong direction altogether!