title: Formatting JSON to be compatible with Datatables with Codeigniter
body: <p>I have encountered a problem while working with the CI and Datatables
  , can someone help me with this</p>
  
  <p>Source Code<br>
  Modal code</p>
  
  <pre><code>    public function all() {
      $query = $this-&gt;db-&gt;get($this-&gt;table);
      return $query-&gt;result_array();
      }
  </code></pre>
  
  <p>SQL Returns</p>
  
  <blockquote>
    <p>Array ( [0] => Array ( [id_barang] => 1 [nama_barang] => Seagate HDD External 500GB [stok_barang] => 100 [harga_awal_barang] => 400000 [harga_jual_barang] => 600000 ) [1] => Array ( [id_barang] => 2 [nama_barang] => USB 8gb Advan [stok_barang] => 50 [harga_awal_barang] => 50000 [harga_jual_barang] => 80000 ) )</p>
  </blockquote>
  
  <p>Controller Code</p>
  
  <pre><code>        public function test(){
          $this-&gt;load-&gt;model('gudang_model');
          $data=$this-&gt;gudang_model-&gt;all();
          $output=array();
          foreach ($data as $row) {
          //$column = array();
          for ($i=0; $i&lt;count($data); $i++) {
                          $column[] = $row;
          }
                      $output['data'] = $column;
          }
          echo json_encode($output);    
      }
  </code></pre>
  
  <p>Result</p>
  
  <blockquote>
    <p>{"data":[{"id_barang":"1","nama_barang":"Seagate HDD External 500GB","stok_barang":"100","harga_awal_barang":"400000","harga_jual_barang":"600000"},{"id_barang":"1","nama_barang":"Seagate HDD External 500GB","stok_barang":"100","harga_awal_barang":"400000","harga_jual_barang":"600000"},{"id_barang":"2","nama_barang":"USB 8gb Advan","stok_barang":"50","harga_awal_barang":"50000","harga_jual_barang":"80000"},{"id_barang":"2","nama_barang":"USB 8gb Advan","stok_barang":"50","harga_awal_barang":"50000","harga_jual_barang":"80000"}]}</p>
  </blockquote>
  
  <p>Can Someone help me to know how the loop in controller have the results like this</p>
  
  <blockquote>
    <p>{"data":[["1","Seagate HDD External 500GB","100","400000"],["2","USB 8gb Advan","50","50000","80000"]]}</p>
  </blockquote>
  
  <p>Thank You</p>