title: Why are all indices in an array 0?
body: <p>Why does the following code output <code>0</code> indices?</p>
  
  <p>I want the indices to be: <code>0 1 2 3 4 ...</code>. How do I fix it?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>foreach ($query-&gt;result() as $row){
      $data = json_decode($row-&gt;residence,true);
      foreach($data as $datum){
          $newArray = array_chunk($datum['units'], 3);
          foreach($newArray as $newA){
              $output = array(implode(",",$newA));
              echo print_r($output).'&lt;br&gt;'; //this is output
          }
      }
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <blockquote>
    <p>Array ( [0] => salam,11,11 ) 1<br> Array ( [0] => khobe,22,22 ) 1<br>
    Array ( [0] => salam,55,55 ) 1<br> Array ( [0] => khobe,66,66 ) 1<br></p>
  </blockquote>
  
  <p>I want this output:</p>
  
  <blockquote>
    <p>Array ( [0] => salam,11,11 ) 1<br> Array ( [1] => khobe,22,22 ) 1<br>
    Array ( [2] => salam,55,55 ) 1<br> Array ( [3] => khobe,66,66 ) 1<br></p>
  </blockquote>
  
  <p><strong>Update:</strong></p>
  
  <p>My JSON encoded in the database:</p>
  
  <pre><code>[{
      "units": ["salam", "11", "11", "khobe", "22", "22"],
  }, {
      "units": ["salam", "55", "55", "khobe", "66", "66"],
  }]
  </code></pre>