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"});
----------------------------
以上是接收到的数据格式。怎么处理成数组。 ??
谢谢
回复讨论(解决方案)
$arr = json_decode($json, true);
$arr = json_decode($json, true);
不行啊。你是。复制上面json试试看
$str = '{"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"}'; $json = json_decode($str,true); var_dump($json);
$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"});';$a = json_decode(preg_replace('/.*\((.+)\).*/', '$1', $s), 1);print_r($a);
Array( [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] => Array ( [0] => Array ( [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 ) [1] => Array ( [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 ) [2] => Array ( [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 ) [3] => Array ( [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)