$res['result'] = "ok";
$res['msg'] = 'login';
$res['fileinfo'] = array();
while($stmt->fetch()){
$fileinfo['fileid'] = $fileid;
$fileinfo['name'] = $name;
$fileinfo['fujianname'] = $fujianname;
array_push($res['fileinfo'], $fileinfo);
}
echo json_encode($res);
输出的字符串如下:
复制代码 代码如下:{"result":"ok","msg":"login","fileinfo":[{"fileid":113,"name":"jishumingcheng","fujianname":"test.txt_test_20161005214223"},{"fileid":114,"name":"wodejishu","fujianname":"test.txt_test2_20161005230610"}]}