title: PHP to Javascript multidimensional array
body: <p>I'm trying to send a PHP array to Javascript.</p>
  
  <p>So far i was only sending a single array in Json to my javascrpt ajax;</p>
  
  <p>The PHP part so far works like that;</p>
  
  <p>If I have an error in my request;</p>
  
  <pre><code>$data[0] = 'false';
  $data[1] = 'Error message';
  </code></pre>
  
  <p>If there is no error;</p>
  
  <pre><code>$data[0] = 'OK';
  $data[1] = 'html content to display';
  </code></pre>
  
  <p>I want to send multidimensional array like;</p>
  
  <pre><code> $data[0] = 'OK';
   $data[1] = 'html content to display';
  
   $data[1][0] = 'OK';
   $data[1][1] = 'another html content to display';
  </code></pre>
  
  <p>The Javascript function that passes the request;</p>
  
  <pre><code>function load(action,container){
      return new Promise(function (resolve, reject) {
          //alert(container);
          $.ajax({
              url: '/ajax.php',
              type: 'post',
              dataType: 'json',
              data: { 'query': 'true', 'action': action, 'container': container },
              success: function (data, status) {
                  console.log(data[0] + ' : FOR ' + action);
                  if (data[0] === 'false') {
                      $("#errorBox").addClass('visible');
                       for (var i = 1; i &lt; data.length; i++) {
                          $('#errMsg').append(data[i]+'&lt;br&gt;');
                          $('#console').prepend('&lt;span class="consoleError"&gt;ERREUR : &lt;/span&gt;' + data[i] + '&lt;br&gt;');
                      }
                      $("#errorBox").show();
                  }
                  else if (data[0] === 'OK') {
                      resolve(data);
                      $(document).ready(function () {
                       $('#console').prepend('&lt;span class="consoleGood"&gt; Statue: ' + data[0] + '&lt;/span&gt; Requête: ' + action + ' Conteneur:' +container+ '&lt;br&gt;');
                      data.splice(0,1);
                  });
                }
                  return;
              },
              error: function (xhr, desc, err) {
                  console.log(xhr);
                  console.log("Details: " + desc + "\nError:" + err);
                  return;
              }
          }); // end ajax call
      });//promise 
  };
  </code></pre>
  
  <p>On the PHP part I use ;</p>
  
  <pre><code>$data[0]= 'OK';
  $data[1]= 'some content';
  $data[1][0]= 'some more content';
  
  echo json_encode($data);
  </code></pre>
  
  <p>I can get all the data contained in the first level of the array but not the second level.</p>
  
  <p>The console log is showing me:</p>
  
  <pre><code>"&lt;div class="doc_css"&gt;&lt;div class="doc_status"&gt;active&lt;/div&gt;&lt;h1&gt;Mon document&lt;/h1&gt;&lt;p&gt;Le corp de mon document&lt;/p&gt;&lt;div class="doc_post_nfo"&gt;Originalement posté par 1 le 2016-02-13 15:25:35&lt;div class="doc_edit"&gt;Modifier&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;"
  length: 1
  __proto__: Array[0]
  </code></pre>
  
  <p>So what do I have to do the get the second level of the array?</p>