我从cURL中检索到$string
,如下所示:
{"time":0.01,"total_rows":7,"rows":[{"id":968},{"id":969},{"id":970},{"id":971},{"id":972},{"id":973},{"id":974}]}
我想知道如何获得具有最大值的id
(即974),我该如何在PHP中执行此操作?
答案 0 :(得分:5)
$result = '{"time":0.01,"total_rows":7,"rows":[{"id":968},{"id":969},{"id":970},{"id":971},{"id":972},{"id":973},{"id":974}]}';
$json = json_decode($result,true);
$max = max($json["rows"]);
echo $max["id"]; // "974"