title: PHP can't print array elements without using print_r
body: <p>I am using a db query that takes in a state and city then spits out 10 fields. Currently I can only see those fields by using print_r. I tried a suggestion on the <a href="http://php.net/manual/en/function.mysql-list-fields.php" rel="nofollow noreferrer">php manual site</a> a for loop to print the fields however I can't get it to work properly. Here is the code:</p>
  <pre><code>    if (!$result) {
          echo 'Could not run query: ' . mysql_error();
          exit;
      }
      if (mysql_num_rows($result) &gt; 0) {
          while ($row = mysql_fetch_assoc($result)) {
              print_r($row).&quot;&lt;/p&gt;&quot;;
              $arrayLength = count($row);
              for ($i = 0; $i &lt; $arrayLength; $i++){
                  echo &quot;arrayName at[&quot; . $i . &quot;] is: [&quot; .$row[$i] . &quot;]&lt;br&gt;\n&quot;;
              }
                  
                  
          }
  
      }
  </code></pre>
  <p>And this is the result:</p>
  <pre><code>Array ( [id] =&gt; 1299 [zip_code] =&gt; 04011 [city] =&gt; Brunswick [county] =&gt; Cumberland [state_name] =&gt; Maine [state_prefix] =&gt; ME [area_code] =&gt; 207 [time_zone] =&gt; Eastern [lat] =&gt; 43.9056 [lon] =&gt; -69.9646 ) ....
  arrayName at[0] is: []
  arrayName at[1] is: []
  arrayName at[2] is: []
  arrayName at[3] is: []
  arrayName at[4] is: []
  arrayName at[5] is: []
  arrayName at[6] is: []
  arrayName at[7] is: []
  arrayName at[8] is: []
  arrayName at[9] is: []
  </code></pre>
  <p>Any ideas why I am not able to properly print the fields and their values? Also my code fails if the query returns more than one row as the current code doesn't really accommodate it.</p>
  <p>I put $i in the body of the for loop to see if it was working properly. Ideally I would have the field name where $i is and the value to the right of it after the colon.</p>