How to write condition for Json?

Is the json file { "streams" : {
"stream1": { "alive" : 0, "iframe" : "url" },
"stream2": { "alive" : 0, "iframe" : "url" },
....
"stream8": { "alive" : 0, "iframe" : "url" },
} }

how to write the conditions so that when all alive = 0 content displayed

made the beat but something

if ($json->alive[0-8] == 0 ) {
echo '1';
}

Prompt.
July 8th 19 at 11:38
1 answer
July 8th 19 at 11:40
Solution
$sJson = '{"streams":{"stream1":{"alive":0,"iframe":"url" },"stream2":{"alive":0,"iframe":"url"},"stream8":{"alive":0,"iframe":"url"}}}';
$rgJson = json_decode($json, true);
$allDead = true;
foreach($rgJson['streams'] as $stream) {
 if ($stream['alive'] != 0) {
 $allDead = false;
break;
}
}

if ($allDead) {
 echo '1';
}

Find more questions by tags JSON