代码:
<?php
$arr=array();
foreach($data as $row){
$arr['name']=$row->user->username;
$arr['time']=$row->user->time;
};
echo json_encode($arr);
?>
输出的json为什么只有一条内容?
天蓬老师2017-07-04 13:48:02
亲,多看手册,掌握下语法哦。
<?php
$arr=array();
foreach($data as $row){
$t['name']=$row->user->username;
$t['time']=$row->user->time;
$arr[] = $t;
};
echo json_encode($arr);
?>