>  기사  >  백엔드 개발  >  PHP json格式化成数组 怎么办

PHP json格式化成数组 怎么办

WBOY
WBOY원래의
2016-06-13 12:09:411026검색

PHP json格式化成数组 怎么处理?

本帖最后由 kj8629 于 2014-11-12 17:24:56 编辑 jsonp_callback({"msg":"ok","rela_opera":-4,"bimg":"http://v9.pfs.56img.com/images/22/6/justin0842i56olo56i56.com_sc_141525800944hd_b.jpg","vid":"129515958","opera_id":-4,"Subject":"【掘图志】电梯","status":"1","duration":"146001","cpm":1,"tags":"掘图志,,,,","df":[{"url":"http://f8.r.56.com/f8.c178.56.com/flvdownload/21/4/sc_141525800944hd_qqvga.mp4?v=1&t=Qo1wweMf4mTmBotIHXAnVA&r=14513&e=1415869829&tt=146&sz=1701822&vid=129515958","type":"qqvga"},{"url":"http://f8.r.56.com/f8.c196.56.com/flvdownload/19/0/sc_141525800944hd.flv.mp4?v=1&t=UikHLAF7oyFYoHQTT5Q6yg&r=14513&e=1415869829&tt=146&sz=5628144&vid=129515958","type":"qvga"},{"url":"http://f8.r.56.com/f8.c178.56.com/flvdownload/28/4/sc_141525800944hd_clear.flv.mp4?v=1&t=_vATPLKPNqNkRdu-75v9iw&r=14513&e=1415869829&tt=145&sz=10229011&vid=129515958","type":"vga"},{"url":"http://f8.r.56.com/f8.c177.56.com/flvdownload/17/11/sc_141525800944hd_super.flv.mp4?v=1&t=dAGxOUspchPmL5yV3iEKfA&r=14513&e=1415869829&tt=145&sz=20032192&vid=129515958","type":"wvga"}],"cid":"4","user_id":"justin0842"});

----------------------------
以上是接收到的数据格式。怎么处理成数组。 ??

谢谢

------解决思路----------------------
$s = 'jsonp_callback({"msg":"ok","rela_opera":-4,"bimg":"http://v9.pfs.56img.com/images/22/6/justin0842i56olo56i56.com_sc_141525800944hd_b.jpg","vid":"129515958","opera_id":-4,"Subject":"【掘图志】电梯","status":"1","duration":"146001","cpm":1,"tags":"掘图志,,,,","df":[{"url":"http://f8.r.56.com/f8.c178.56.com/flvdownload/21/4/sc_141525800944hd_qqvga.mp4?v=1&t=Qo1wweMf4mTmBotIHXAnVA&r=14513&e=1415869829&tt=146&sz=1701822&vid=129515958","type":"qqvga"},{"url":"http://f8.r.56.com/f8.c196.56.com/flvdownload/19/0/sc_141525800944hd.flv.mp4?v=1&t=UikHLAF7oyFYoHQTT5Q6yg&r=14513&e=1415869829&tt=146&sz=5628144&vid=129515958","type":"qvga"},{"url":"http://f8.r.56.com/f8.c178.56.com/flvdownload/28/4/sc_141525800944hd_clear.flv.mp4?v=1&t=_vATPLKPNqNkRdu-75v9iw&r=14513&e=1415869829&tt=145&sz=10229011&vid=129515958","type":"vga"},{"url":"http://f8.r.56.com/f8.c177.56.com/flvdownload/17/11/sc_141525800944hd_super.flv.mp4?v=1&t=dAGxOUspchPmL5yV3iEKfA&r=14513&e=1415869829&tt=145&sz=20032192&vid=129515958","type":"wvga"}],"cid":"4","user_id":"justin0842"});';<br />$a = json_decode(preg_replace('/.*\((.+)\).*/', '$1', $s), 1);<br />print_r($a);<br />
Array<br />(<br />    [msg] => ok<br />    [rela_opera] => -4<br />    [bimg] => http://v9.pfs.56img.com/images/22/6/justin0842i56olo56i56.com_sc_141525800944hd_b.jpg<br />    [vid] => 129515958<br />    [opera_id] => -4<br />    [Subject] => 【掘图志】电梯<br />    [status] => 1<br />    [duration] => 146001<br />    [cpm] => 1<br />    [tags] => 掘图志,,,,<br />    [df] => Array<br />        (<br />            [0] => Array<br />                (<br />                    [url] => http://f8.r.56.com/f8.c178.56.com/flvdownload/21/4/sc_141525800944hd_qqvga.mp4?v=1&t=Qo1wweMf4mTmBotIHXAnVA&r=14513&e=1415869829&tt=146&sz=1701822&vid=129515958<br />                    [type] => qqvga<br />                )<br /><br />            [1] => Array<br />                (<br />                    [url] => http://f8.r.56.com/f8.c196.56.com/flvdownload/19/0/sc_141525800944hd.flv.mp4?v=1&t=UikHLAF7oyFYoHQTT5Q6yg&r=14513&e=1415869829&tt=146&sz=5628144&vid=129515958<br />                    [type] => qvga<br />                )<br /><br />            [2] => Array<br />                (<br />                    [url] => http://f8.r.56.com/f8.c178.56.com/flvdownload/28/4/sc_141525800944hd_clear.flv.mp4?v=1&t=_vATPLKPNqNkRdu-75v9iw&r=14513&e=1415869829&tt=145&sz=10229011&vid=129515958<br />                    [type] => vga<br />                )<br /><br />            [3] => Array<br />                (<br />                    [url] => http://f8.r.56.com/f8.c177.56.com/flvdownload/17/11/sc_141525800944hd_super.flv.mp4?v=1&t=dAGxOUspchPmL5yV3iEKfA&r=14513&e=1415869829&tt=145&sz=20032192&vid=129515958<br />                    [type] => wvga<br />                )<br /><br />        )<br /><br />    [cid] => 4<br />    [user_id] => justin0842<br />)<br /><br />
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.