if(mysql_affected_rows() > 0)
{
$status = "OK";
while($row = mysql_fetch_array($result)) {
$info[] = array(
'postDate' => $row[1],
'vedioURL' => extractifrem($row[2]),
'like' => $row[3],
'totalView' => $row[4],
'viewTime' => $row[5]
);
}
$output = array(
'status' => $status,
'result' => $info
);
我想将$ output的结果打印为有效的json可读。我正在使用此代码但不能正常工作
$soutput = array();
foreach($output as $v) {
$soutput[key($v)] = current($v);
}
echo json_encode($soutput, 128);
答案 0 :(得分:4)
这样做..
$soutput = array();
foreach($output as $k=>$v) {
$soutput[$k] = $v;
}
echo json_encode($soutput);
答案 1 :(得分:0)
仅使用json_encode($ soutput,true)代替json_encode($ soutput,128);