title: json_encode() on a multidimensional array - with string keys
body: <p>I am creating an very large multidimensional array using PHP. Each object contains Name, ID, ParentID and Children. Children is an array of more objects in the same format. </p>
  
  <p>It is critical I name the IDs of each object - this helps me put each object under the correct parent. (In the code below, I use 101, 102 etc.)</p>
  
  <p>However, the problem I am having is when I return the array in JSON using <code>json_encode</code>. Each 'Children' array is being printed as an object, not an array - as shown in the JSON code below.</p>
  
  <p>As I read on another SO thread <a href="https://stackoverflow.com/a/10778760/1359306">here</a>, they "are made as objects because of the inclusion of string keys" - although they are numbers, they are still strings.</p>
  
  <pre><code>{
  "101": {
      "ID": "101",
      "ParentID": "0",
      "Name": "Root One"
      "Children": {
          "102": {
              "ID": "102",
              "ParentID": "101",
              "Name": "Child One"
          },
          "103": {
              "ID": "103",
              "ParentID": "101",
              "Name": "Child Two",
              "Children": {
                  "104": {
                      "ID": "104",
                      "ParentID": "103",
                      "Name": "Child Child One"
                  }
              }
          },
  </code></pre>
  
  <p>Does anyone know how to overcome this issue?</p>
  
  <p><strong>Edit:</strong> The JSON should look like this (the square brackets are important!):</p>
  
  <pre><code>[
  {
      "ID": "101",
      "ParentID": "0",
      "Name": "Root One",
      "Children": [
          {
              "ID": "102",
              "ParentID": "101",
              "Name": "Child One",
              "Children": [
  </code></pre>