I'm trying to create an ajax search page, which shows live results similar to google.
Right now I am struggling with how to convert a search query such as small dog
to a GET
parameter, in this case it would be "searchresults?search=small+dog"
. The thing I want is to replace all white space between words to +
and to remove whitespaces before and after words.
I think it's possible with regex, or is there some javascript or jquery function to encode that?
I tried using escape
, encodeURI
, ... , but it made whitespace %20
. Will PHP understand that they are multiple words?