title: loop through php arrayray with jquery
body: <p>I have a php array:</p>
  
  <pre><code>print_r($names);
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>Array ( [adam] =&gt; adam [John] =&gt; John [Clair] =&gt; Clair [Sue] =&gt; Sue) 
  </code></pre>
  
  <p>I want to loop through the array with jquery/javascript.</p>
  
  <p>I set the javascript variable equal to that of the PHP array:</p>
  
  <pre><code>var jnames="&lt;?php print($names); ?&gt;";
  </code></pre>
  
  <p>How can I loop through the array jnames?</p>
  
  <pre><code>for(var i=0; i &lt; jnames.length; i++)
    {
      alert(jnames[i]);
    }
  </code></pre>
  
  <p>This simply returns A, then R, then R, then A, then Y for array.</p>
  
  <p>How can I get this to return the proper value of the array? being adam, john, clair etc.</p>
  
  <p>Thanks.</p>