title: PHP echo automatically replaces "&" with "&amp;"
body: <p>I'm making a PHP function that converts a $_GET array into the URL string format..</p>
  
  <p>e.g. <code>Array('key1'=&gt;'value1', 'key2'=&gt;'value2')</code>
  gets converted to: <code>?key1=value1&amp;key2=value2</code></p>
  
  <p>I think the function it's doing its work correctly. But when I echo the result, in the HTML page all instances of "<code>&amp;</code>" are replaced by "<code>&amp;amp;</code>". So, the conversion in the browser ends up being <code>?key1=value1&amp;amp;key2=value2</code>. </p>
  
  <p>Here's my PHP function:</p>
  
  <pre><code>/**
   *
   * @param Array $GETArray Pass in the associative $_GET array here.
   * @return string The $GETArray converted into ?key=value&amp;key2=value2&amp;... form. 
   */
  function strGET($GETArray) {
      if (sizeof($GETArray) &lt; 1) {
          return '';
      }
  
      $firstkey = key($GETArray);
      $firstvalue = $GETArray[$firstkey];
  
      $sofar = "?$firstkey=$firstvalue";
  
      array_shift($GETArray);
  
      foreach ($GETArray as $key =&gt; $value) {
          $sofar .= '&amp;'."$key=$value";
      }
      return $sofar;
  }
  </code></pre>