Php echo highest number from Json -


i'm searching external json page, $a , echoing $b.

<?php $jsonurl = "site.com/json.json"; $json = file_get_contents($jsonurl); $json_output = json_decode($json);  foreach ($json_output $page) {     foreach($page->x $x) {         if (isset($x->a)) {             $a= $x->a;             $b  = $x->b;     if ( $a == 'hello' || $a == 'hi'){     echo $b 

$b number, , there 1 number or perhaps 2 or three. if there's more one, tidy way of echoing largest value of $b rather of them should more 1 value exist?

the numbers unknown can't use echo max or similar.

$number = array(); foreach ($json_output $page) {     foreach($page->x $x) {         if (isset($x->a)) {             $a= $x->a;             $b  = $x->b;             if ( $a == 'hello' || $a == 'hi'){                 $numbers[] = $b;             }         }     } } echo max($numbers); 

see php.net


Comments