[Solved] How can I foreach this array object?


Here You go:

<?php
$list = (object)[];
$list->egame = 
[
(object)['platform_name'=>'TT', 'game'=>(object)[(object)['game_name'=>'game1', 'info'=>'test1'],(object)['game_name'=>'game2', 'info'=>'test2'],(object)['game_name'=>'game3', 'info'=>'test3']]],

(object)['platform_name'=>'TG', 'game'=>(object)[(object)['game_name'=>'game4', 'info'=>'test4'],(object)['game_name'=>'game5', 'info'=>'test5']]],

(object)['platform_name'=>'TBIN', 'game'=>(object)[(object)['game_name'=>'game6', 'info'=>'test6']]]
];

foreach ( $list->egame as $eg ) {
    foreach ( $eg->game as $game ) {
        echo "game: " . $game->game_name . " info: " . $game->info . "<br>";
    }
}

?>

Edit #1
Includes platform:

foreach ( $list->egame as $eg ) {        
        foreach ( $eg->game as $game ) {
            echo "platform: " . $eg->platform_name . " game: " . $game->game_name . " info: " . $game->info . "<br>";
        }
 }

1

solved How can I foreach this array object?