php-json多维数组处理,如何取值。

WBOY
Release: 2016-06-23 13:11:18
Original
2430 people have browsed it

一个ajax调用从阿里大鱼api取得了一串返回值。如下:{"alibaba_aliqin_fc_sms_num_send_response":{"result":{"err_code":"0","model":"101119416903^1101601857156","success":true},"request_id":"1476c431qgbi4"}}
我可以用$starr= json_decode($str,true); 获取$starr数组。但是如何取得数组$starr里面我需要的 success数据呢?我需要通过success来做进一步判断。还有。返回值是json数据吗?如果是,我传到前台用jquery ajax。如何获取success的值呢?


回复讨论(解决方案)

$str = '{"alibaba_aliqin_fc_sms_num_send_response":{"result":{"err_code":"0","model":"101119416903^1101601857156","success":true},"request_id":"1476c431qgbi4"}}';$starr= json_decode($str,true);echo $starr['alibaba_aliqin_fc_sms_num_send_response']['result']['success'];
Copy after login


js:
json.alibaba_aliqin_fc_sms_num_send_response.result.success
也可以写作
json['alibaba_aliqin_fc_sms_num_send_response']['result']['success']

是的。楼上正解,我已经成功调用了。不能用 $starr[0][0][1]之类的

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!