title: Retrieving whole URL, even with ampersands, using _GET
body: <p>I made a quick script to retrieve and parse XML. It's simply for internal use and I though that appending the feed URL to the script address would be a convenient way to initialize the script...</p>
  
  <blockquote>
    <p>www.example.com/feed_analyzer.php?url=www.example.com/an_xml_feed.xml</p>
  </blockquote>
  
  <p>Then I simply grab the URL...</p>
  
  <pre><code>if (isset($_GET['url'])) {
    $xml_url = $_GET['url']
  }
  </code></pre>
  
  <p>...retrieve the file at $xml_url, parse etc.</p>
  
  <p>All was fine until this URL came along with pesky parameters:</p>
  
  <blockquote>
    <p>www.example.com/an_xml_feed.xml?foo=bar&amp;rice=chips</p>
  </blockquote>
  
  <p>That of course left me with the URL "www.example.com/an_xml_feed.xml"</p>
  
  <p>I have managed to "patch back together" the whole URL using this clunky code:</p>
  
  <pre><code>if (isset($_GET['url'])) {
    foreach($_GET as $key =&gt; $value){
     $got .= "&amp;".$key."=".$value;
    }
    $xml_url = ltrim($got,'&amp;url=');
  }
  </code></pre>
  
  <p>Can someone please suggest a more elegant approach.</p>