我正在将 dataTables 与 Codeigniter 一起使用,但我遇到了问题。我收到一条消息:
array_push() expects parameter 1 to be array, null given
结果是{"aaData":null}
我想得到这样的东西:{ "aaData": [ ["test","test","test"] ] }
代码:
$result = $this->lol_model->get();
//result = Array ( [0] => stdClass Object ( [test] => 12345 [test2] => 1842 07 03 [test3] => lol ) )
$aaData = array();
foreach($result as $row) {
array_push($json["aaData"],array(
$row->test,
$row->test2,
$row->test3
));
}
echo json_encode($json);