encode json using php?

前端 未结 5 1760
滥情空心
滥情空心 2020-12-06 07:33

I want to get json with php encode function like the following



        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 08:17

    build it all into an array first, then encode the whole thing in one go:

    $outputdata = array();
    while($row = mysql_fetch_array($result)) {
        $outputdata[] = $row;
    }
    
    echo json_encode($outputdata);
    

提交回复
热议问题