title: Split an array within an array (Mysql, PHP and Ajax)
body: <p>I have a database with 5 columns and multiple rows. I'm using PHP to fetch the data and echo it as JSON as an array. The way it echoes it is the data in each row is an array and the rows themselves are an array (array within an array).</p>
  
  <p>Now I bring the data in using Ajax and want to split the array within an array. I can only split down the rows so far. How would I split further?</p>
  
  <p>Here's the PHP:</p>
  
  <pre><code>  //==== FETCH DATA
    $result = mysql_query("SELECT * FROM $tableName");
  
    //==== PUT DATA INTO ARRAY
    $array = array();
    while ($row = mysql_fetch_row($result)) {
      $array[] = $row;
    }
  
    //==== ECHO AS JSON
    echo json_encode($array);
  </code></pre>
  
  <p>Here's the Ajax:</p>
  
  <pre><code>$.ajax({                                      
    url: 'assets/php/results.php',    
    data: "",
    dataType: 'json',                  
    success: function(data){
  
      //==== FETCH DATA FIELDS
      var row1 = data[0];
      var row2 = data[1];
  
      //==== UPDATE HTML WITH DATA
      $('#r-col span.row1').html(row1);
      $('#r-col span.row2').html(row2);
    }
  });
  </code></pre>