$data = $sql->fetchAll(PDO::FETCH_ASSOC);
//2D array (when mysql fetchAll, it came out like this)
Array
(
[0] => Array
(
[id] => 20,
[title] => "testing1",
[time] => 1471936066
)
[1] => Array
(
[id] => 18,
[title] => "testing2",
[time] => 1467780284
)
);
//array object
Array(
{
"id" : 20,
"title" : "testing1",
"time" : 1471936066
},
{
"id" : 18
"title" : "testing2",
"time" : 1467780284
}
);
我有一个关于发送数据格式到后端查看的问题(有时它需要是JS的JSON字符串,但不是所有时间)
我应该发送2D数组来查看还是应该将数据转换为数组对象并将其发送到视图文件?