php json_encode问题

WBOY
Release: 2016-06-23 14:15:38
Original
853 people have browsed it

php json_encode PHP JSON json_encode

rt小弟今天遇到个奇怪的问题

只是使用json_encode转换的json编码,圈出的地方是应该是个自然序列下标数组,可不知为何转换成了对象,但下标却标记为0,请了解的大神们为小弟出出主意,谢谢了。

回复讨论(解决方案)

建议把你的代码贴出来以供分析。

当数组的下标不以0开始递增连续时,就是关联数组了

$ar =array(1=>'a',0=>'b');echo json_encode($ar); //{"1":"a","0":"b"}$ar =array('a',2=>'b');echo json_encode($ar); //{"0":"a","2":"b"}
Copy after login

代码就是$json = json_encode($array, true);

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!