php json获取问题

Kvin 发布于 2015/06/24 16:31
阅读 507
收藏 0
PHP

http://www.mogujie.com/cps/open/items_v2?uid=125ar1o&ids=16q7g2m

{"16q7g2m":{"id":"16q7g2m","url":"http:\/\/shop.mogujie.com\/detail\/16q7g2m","murl":"http:\/\/m.mogujie.com\/x5\/detail\/16q7g2m","title":"ONOZA \u6a31\u6843\u5c0f\u4e38\u5b50002\u77ed\u8896T\u6064","tags":"t\u6064,\u65b0\u6b3e,\u97e9\u7248,\u4e0a\u8863,\u4f11\u95f2,\u5b66\u751f,\u663e\u7626,\u5b66\u9662\u98ce","properties":"\u9886\u578b:\u5706\u9886;\u6750\u8d28:\u68c9;\u8896\u578b:\u5e38\u89c4\u8896;\u8896\u957f:\u77ed\u8896;\u8863\u957f:\u5e38\u89c4\u6b3e\uff0855-65cm\uff09;\u7248\u578b:\u4fee\u8eab;\u56fe\u6848:\u5361\u901a;\u98ce\u683c:\u5361\u54c7\u4f0a;","price":"78.00","content":"\u9752\u6625\u65f6\u5c1a\uff0c\u7248\u578b\u7b80\u7ea6\uff0c\u4e2a\u6027\u767e\u642d","category":"\u670d\u9970\u978b\u5305-\u5973\u88c5-\u4e0a\u88c5-T\u6064","shopid":"16608","shopname":"ONOZA\u5bb6","sale":5336,"latestSale":6443,"picture":"http:\/\/s18.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ie2dsylche3gmmldmyytambqgiyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_iezgmyjwgm3wmmldmyytambqmmyde_800x1200.jpg;http:\/\/s20.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ie2tkzdegy3wmmldmyytambqhayde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_iezweyjwmy3wmmldmyytambqgyyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ieywcylbha4gmmldmyytambqmeyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_iezdinlemq4gmmldmyytambqmmyde_800x1200.jpg;http:\/\/s20.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ieytemjugi4wmmldmyytambqmeyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ieywgmjygy4wmmldmyytambqmeyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ieytqnlfme4wmmldmyytambqmeyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150305\/1hcmk7_iezwkzdfmq4wmmldmyytambqgyyde_800x1200.jpg;http:\/\/s20.mogucdn.com\/b7\/pic\/150305\/1hcmk7_ie2wknbugfqwmmldmyytambqhayde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150406\/1hcml7_ie2tqzrug5swcnbwgazdambqhayde_800x1200.jpg;http:\/\/s18.mogucdn.com\/b7\/pic\/150509\/1hcml7_ie2wgmztmy2tazjqgezdambqhayde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150512\/1hcml7_ie2tmzjygaydgzbrgezdambqhayde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150512\/1hcml7_iezwgmlgg43wmzbrgezdambqgyyde_800x1200.jpg;http:\/\/s17.mogucdn.com\/b7\/pic\/150512\/1hcml7_iezwcyleha3wmzbrgezdambqgyyde_800x1200.jpg;http:\/\/s20.mogucdn.com\/b7\/pic\/150305\/1hcmk7_iezwmojwg42wmmldmyytambqgyyde_800x1200.jpg","discount":7,"nowprice":"58.50","commission":"8.0","onShelfTime":"2015-05-12 11:32:59","score":"{\"price\":4.8,\"quality\":4.9,\"style\":4.5}","weight":12890.68,"cfav":35}}

我想单单获取price\":4.8,   4.8这个数据  请问php怎么写

加载中
0
Kvin
Kvin
帮帮忙啊
0
Buvsoft
Buvsoft
$c=json_decode($json);//
echo $c->price;

或
$c=json_decode($json,true);//
echo $c['price'];



0
Kvin
Kvin

引用来自“Buvsoft”的评论

$c=json_decode($json);//
echo $c->price;

或
$c=json_decode($json,true);//
echo $c['price'];



不行啊
0
Kvin
Kvin
大家帮帮啊
0
王瑞平
王瑞平

层级关系

$c->16q7g2m->score->price;

r-ricky
r-ricky
$c->16q7g2m->price;会有语法错误,可以通过foreach避开: $eles = json_decode($json); foreach ($eles as $ele) { echo($ele->price); }
0
红星xx
红星xx
echo $c['16q7g2m']['price']




0
Kvin
Kvin

引用来自“红星xx”的评论

echo $c['16q7g2m']['price']




万分感谢
0
王瑞平
王瑞平

"score":"{\"price\":4.8,\"quality\":4.9,\"style\":4.5}"

?

0
Kvin
Kvin

"picture": "http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzgqokbozbguwkugfjeg5sckzsew_450x600.jpg;http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzgqokbozbguwkugfjeg5sckzsew_450x600.jpg;http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzgqokbozbguwkugfjeg5sckzsew_450x600.jpg;http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzhqtkwozbdiqlwgfjeg5sckzsew_450x600.jpg", 

这个能让它单独

http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzgqokbozbguwkugfjeg5sckzsew_450x600.jpg

http://s12.mogujie.cn/b7/pic/140424/10f3hy_kqzgqokbozbguwkugfjeg5sckzsew_450x600.jpg

这样子形式输出吗

0
OSC首席键客
OSC首席键客
擦,json都给你了,你还拿不到要的数据?
返回顶部
顶部