PHP数组发送json

时间:2017-03-17 03:25:19

标签: php arrays json

我有这个代码

function get_data_tbl()
{
    $dt = $this->penilaian_model->get_data_tbl();
    foreach ($dt as $key => $value) {
        $date_in = $value->date_in;
        $nmloket = $value->nama;
        $keterangan = $value->keterangan;
        $sgtpuas = $value->sangat_puas;
        $puas = $value->puas;
        $tdkpuas = $value->tidak_puas;
        $total = $value->total;
        $nilai = $value->nilai;
        $output[] = [$date_in.','.$nmloket.','.$keterangan.','.$sgtpuas.','.$puas.','.$tdkpuas.','.$total.','.$nilai];            
    }
    send_json($output);
}

这就是输出

  

[[“2017-03-16,A,Informasi,0,1,0,1,60”],[“2017-03-16,C,Tanggapan SPHP,0,1,0,1,60 “]]

但我想要像这样的输出

  

[[“2017-03-16”,“A”,“Informasi”,“0”,“1”,“0”,“1”,“60”],[“2017-03-16” ,“C”,“Tanggapan SPHP”,“0”,“1”,“0”,“1”,“60”]]

请帮助

1 个答案:

答案 0 :(得分:0)

如果您希望它们是单独的数组元素,请不要将它们与.连接起来。这就是一个字符串。

$output[] = [$date_in, $nmloket, $keterangan, $sgtpuas, $puas, $tdkpuas, $total, $nilai];