If online show this, else show this (not working)

If you compare mine to yours, you will see the mistake.

In the last For each, you use
$game = $chdata[‘channel’][‘game’]
$logo = $chdata[‘channel’][‘logo’];

Can you perhaps tell me where $chdata is defined?
is it in that loop, or is it set before and not changed?

now to fix it:

  foreach ($live as $name => $channel)

Every pair, you read the $name and the JSON OBJECT $channel corresponding to that name.
Perhaps, use that data to get the correct game?

as seen from my snippet before:

foreach ($live as $name => $channel) {
   if($channel != null){
       $game = $channel['game']; 
.... ETC
}
1 Like