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