安逸丫 发表于 2020-1-27 14:47

PHP咋把json转换成数组

本帖最后由 安逸丫 于 2020-1-27 14:48 编辑

{"songs":[{"name":"四重罪孽","id":430053202,"pst":0,"t":0,"ar":[{"id":12077190,"name":"易世樊花","tns":[],"alias":[]},{"id":12025552,"name":"双笙","tns":[],"alias":[]},{"id":12084085,"name":"汉南蛮久","tns":[],"alias":[]}],"alia":[],"pop":100.0,"st":0,"rt":"","fee":0,"v":43,"crbt":null,"cf":"","al":{"id":34871558,"name":"易世樊花2016翻唱集合","picUrl":"https://p1.music.126.net/NbBSu6EjFWTX1yvTTF2Sjg==/17699938184287815.jpg","tns":[],"pic_str":"17699938184287815","pic":17699938184287815},"dt":233363,"h":{"br":320000,"fid":0,"size":9344566,"vd":-31900.0},"m":{"br":192000,"fid":0,"size":5606757,"vd":-29200.0},"l":{"br":128000,"fid":0,"size":3737853,"vd":-27700.0},"a":null,"cd":"1","no":22,"rtUrl":null,"ftype":0,"rtUrls":[],"djId":0,"copyright":2,"s_id":0,"mark":0,"originCoverType":0,"mv":0,"mst":9,"cp":0,"rtype":0,"rurl":null,"publishTime":1473741044348}],"privileges":[{"id":430053202,"fee":0,"payed":0,"st":0,"pl":320000,"dl":320000,"sp":7,"cp":1,"subp":1,"cs":false,"maxbr":320000,"fl":999000,"toast":false,"flag":0,"preSell":false}],"code":200}

各位大佬咋把上面的“双笙” 和 “图片地址”
取出转换为PHP数组啊求助:'(weeqw

琴似蓝调 发表于 2020-1-27 18:32

<?php
$res='{"songs":[{"name":"四重罪孽","id":430053202,"pst":0,"t":0,"ar":[{"id":12077190,"name":"易世樊花","tns":[],"alias":[]},{"id":12025552,"name":"双笙","tns":[],"alias":[]},{"id":12084085,"name":"汉南蛮久","tns":[],"alias":[]}],"alia":[],"pop":100.0,"st":0,"rt":"","fee":0,"v":43,"crbt":null,"cf":"","al":{"id":34871558,"name":"易世樊花2016翻唱集合","picUrl":"https://p1.music.126.net/NbBSu6EjFWTX1yvTTF2Sjg==/17699938184287815.jpg","tns":[],"pic_str":"17699938184287815","pic":17699938184287815},"dt":233363,"h":{"br":320000,"fid":0,"size":9344566,"vd":-31900.0},"m":{"br":192000,"fid":0,"size":5606757,"vd":-29200.0},"l":{"br":128000,"fid":0,"size":3737853,"vd":-27700.0},"a":null,"cd":"1","no":22,"rtUrl":null,"ftype":0,"rtUrls":[],"djId":0,"copyright":2,"s_id":0,"mark":0,"originCoverType":0,"mv":0,"mst":9,"cp":0,"rtype":0,"rurl":null,"publishTime":1473741044348}],"privileges":[{"id":430053202,"fee":0,"payed":0,"st":0,"pl":320000,"dl":320000,"sp":7,"cp":1,"subp":1,"cs":false,"maxbr":320000,"fl":999000,"toast":false,"flag":0,"preSell":false}],"code":200}';

$r=json_decode($res,true);
print_r($r['songs']);
print_r($r['songs']);

安逸丫 发表于 2020-1-29 00:06

琴似蓝调 发表于 2020-1-27 18:32


谢谢大佬
页: [1]
查看完整版本: PHP咋把json转换成数组