使用该
json_depre函数将JSON字符串转换为对象数组,然后遍历该数组直到找到所需的对象:
$str = '{ "people":[ { "id": "8080", "content": "foo" }, { "id": "8097", "content": "bar" } ]}';$json = json_depre($str);foreach ($json->people as $item) { if ($item->id == "8097") { echo $item->content; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)