json数组问题,在线等

WBOY
Release: 2016-06-23 13:47:36
Original
859 people have browsed it

json数组问题,做为接口输出json,在线等
有两条数组$result1和$result2,输出json数组的时候echo json_encode($result1);    echo json_encode($result2);这样输出两条可以吗?好像是只能输出一条,怎样将这两条合并成一个,输出echo json_encode($result);


回复讨论(解决方案)

echo json_encode( array($result1, $result2) );
Copy after login

echo json_encode( array('result1' => $result1,'result2' => $result2) );
Copy after login

同上,你将两个数组搞成连接成一个,到浏览器端分开处理就可以了

先合?成一???,然後在?行json_encode
$result = array($result1, $result2);
echo json_encode($result);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!