3

I have a $string retrieved from cURL like this:

{"time":0.01,"total_rows":7,"rows":[{"id":968},{"id":969},{"id":970},{"id":971},{"id":972},{"id":973},{"id":974}]}

I would like to know how to get the id that has the largest value (i.e 974), how can I do this in PHP?

Antony
  • 14,900
  • 10
  • 46
  • 74
Bwyss
  • 1,736
  • 3
  • 25
  • 48

1 Answers1

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"
Antony
  • 14,900
  • 10
  • 46
  • 74