title: PHP Array to jQuery array with JSON. ($.post, parseJSON, json_encode)
body: <p>I am trying to get a php file setup to return the results of a MySQL database query from a jQuery AJAX call. The returned results <strong>will be an array</strong>.  I have a very basic start where I am just getting some basic data back and forth to and from the php file, but am stuck with some basic syntax issues:</p>
  
  <p>The PHP code:</p>
  
  <pre><code>$arr = array ('a'=&gt;1,'b'=&gt;2,'c'=&gt;3,'d'=&gt;4,'e'=&gt;5);  
  echo json_encode($arr); 
  </code></pre>
  
  <p>The jQuery code:</p>
  
  <pre><code>$.post("dbFile.php", str, function(theResponse){
       alert('the response: ' + theResponse);
       var obj = $.parseJSON(theResponse);
       alert(obj.a);
  </code></pre>
  
  <p>I can print out obj.a, obj.b, obj.c... no problem.  The problem is I will be incrementing a counter as I increment through the MySQL results.  So, the array does not use letters, it uses numbers: </p>
  
  <pre><code>$arr[$i] = mysqlresults ... $i++;
  </code></pre>
  
  <p>So, in the JavaScript/jQuery I have an object (not an array). I can print out obj.a for example, but I can not print out obj.2 (for example). In other words, if I replace the letters with numbers in the php array, I don't know how to print them out in JavaScript/jQuery.  Can I change the object that parseJSON returns into an array somehow (so that I can cycle through it)?</p>