如何切割这根巨大的绳子?我需要first ID
,"的数据。最好是字符串输出为:
"id":1,"name":"site1","has_doneit":true,"destination":"4613"
这可能吗?或者,如果没有任何其他方式获取名称:" site1"和has_doneit:true会很好。
{"needs_complete":true,"has_done":true,"sites":[
{"id":1,"name":"site1","has_doneit":true,"destination":"4613"},{"id":2,"name":"site2","has_doneit":true,"destination":"4613"},{"id":3,"name":"site3","has_doneit":true,"destination":"4339"},{"id":4,"name":"site4","has_doneit":true,"destination":"4340"},{"id":5,"name":"site5","has_doneit":true,"destination":"4341"},
{"id":6,"name":"site6","has_doneit":true,"destination":"4622"},{"id":7,"name":"site7","has_doneit":true,"destination":"4623"},{"id":8,"name":"site8","has_doneit":true,"destination":"4828"},
{"id":9,"name":"site9","has_doneit":true,"destination":"4829"},{"id":10,"name":"site10","has_doneit":true,"destination":"4861"}]}
答案 0 :(得分:0)
这似乎是一个JSON字符串,所以使用Json Parser ......
$parsedStr = json_decode($yourString, true);
您可以访问$parsedStr['sites']
因此,要访问第一个网站的ID:
echo $parsedStr['sites'][0]['id'];