title: Manipulate a url string by adding GET parameters
body: <p>I want to add GET parameters to URLs that may and may not contain GET parameters without repeating <code>?</code> or <code>&amp;</code>.</p>
  
  <p>Example:</p>
  
  <p>If I want to add <code>category=action</code></p>
  
  <pre><code>$url="http://www.acme.com";
   // will add ?category=action at the end
  
  $url="http://www.acme.com/movies?sort=popular";
   // will add &amp;category=action at the end
  </code></pre>
  
  <p>If you notice I'm trying to not repeat the question mark if it's found.</p>
  
  <p>The URL is just a string.</p>
  
  <p>What is a reliable way to append a specific GET parameter?</p>