title: Fastest way to implode an associative array with keys
body: <p>I'm looking for a fast way to turn an associative array in to a string. Typical structure would be like a URL query string but with customizable separators so I can use '<code>&amp;amp;</code>' for xhtml links or '<code>&amp;</code>' otherwise.</p>
  
  <p>My first inclination is to use <code>foreach</code> but since my method could be called many times in one request I fear it might be too slow.</p>
  
  <pre><code>&lt;?php
  $Amp = $IsXhtml ? '&amp;amp;' : '&amp;';
  $Parameters = array('Action' =&gt; 'ShowList', 'Page' =&gt; '2');
  $QueryString = '';
  foreach ($Parameters as $Key =&gt; $Value)
          $QueryString .= $Amp . $Key . '=' . $Value;
  </code></pre>
  
  <p>Is there a faster way?</p>