Home  >  Article  >  Backend Development  >  json数组问题,在线等

json数组问题,在线等

WBOY
WBOYOriginal
2016-06-23 13:47:36894browse

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


回复讨论(解决方案)

echo json_encode( array($result1, $result2) );

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

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

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

Statement:
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