Как из одного многомерного массива собрать свой на php?
есть такой массив, который я получаю.
[tournament] => stdClass Object
(
[name] => Barcelona, Spain
[slug] => barcelona-spain
[category] => stdClass Object
(
[name] => ATP
[slug] => atp
[sport] => stdClass Object
(
[name] => Tennis
[slug] => tennis
[id] => 5
)
[id] => 3
[flag] => atp
)
[uniqueTournament] => stdClass Object
(
[name] => Barcelona
[slug] => barcelona
[category] => stdClass Object
(
[name] => ATP
[slug] => atp
[sport] => stdClass Object
(
[name] => Tennis
[slug] => tennis
[id] => 5
)
[id] => 3
[flag] => atp
)
[userCount] => 0
[id] => 2407
[hasEventPlayerStatistics] =>
)
[id] => 90688
)
[roundInfo] => stdClass Object
(
[round] => 28
[name] => Semifinals
[cupRoundType] => 2
)
[customId] => qXYsvGHb
[status] => stdClass Object
(
[code] => 0
[description] => Not started
[type] => notstarted
)
[winnerCode] => 0
[homeTeam] => stdClass Object
(
[name] => Sinner J.
[slug] => sinner-jannik
[shortName] => Sinner J.
[userCount] => 0
[type] => 0
[id] => 206570
[subTeams] => Array
(
)
[teamColors] => stdClass Object
(
[primary] => #52b030
[secondary] => #52b030
[text] => #ffffff
)
)
[awayTeam] => stdClass Object
(
[name] => Tsitsipas S.
[slug] => tsitsipas-stefanos
[shortName] => Tsitsipas S.
[userCount] => 0
[type] => 0
[id] => 122366
[subTeams] => Array
(
)
[teamColors] => stdClass Object
(
[primary] => #52b030
[secondary] => #52b030
[text] => #ffffff
)
)
[homeScore] => stdClass Object
(
)
[awayScore] => stdClass Object
(
)
[time] => stdClass Object
(
)
[changes] => stdClass Object
(
[changeTimestamp] => 0
)
[hasGlobalHighlights] =>
[id] => 9486886
[startTimestamp] => 1619263800
[slug] => sinner-tsitsipas
[periods] => stdClass Object
(
[point] => Game
[current] => Match
[period1] => 1st set
[period2] => 2nd set
[period3] => 3rd set
[period4] => 4th set
[period5] => 5th set
)
[finalResultOnly] =>
Я хочу его немного переделать для удобства вывода в будущем и получить вот такой массив
[90688] => stdClass Object
(
[name] => Barcelona, Spain
[slug] => barcelona-spain
[category] => stdClass Object
(
[name] => ATP
[slug] => atp
[sport] => stdClass Object
(
[name] => Tennis
[slug] => tennis
[id] => 5
)
[id] => 3
[flag] => atp
)
[uniqueTournament] => stdClass Object
(
[name] => Barcelona
[slug] => barcelona
[category] => stdClass Object
(
[name] => ATP
[slug] => atp
[sport] => stdClass Object
(
[name] => Tennis
[slug] => tennis
[id] => 5
)
[id] => 3
[flag] => atp
)
[userCount] => 0
[id] => 2407
[hasEventPlayerStatistics] =>
)
[id] => 90688
[9486886] => stdClass Object
(
[roundInfo] => stdClass Object
(
[round] => 28
[name] => Semifinals
[cupRoundType] => 2
)
[customId] => qXYsvGHb
[status] => stdClass Object
(
[code] => 0
[description] => Not started
[type] => notstarted
)
[winnerCode] => 0
[206570] => stdClass Object
(
[name] => Sinner J.
[slug] => sinner-jannik
[shortName] => Sinner J.
[userCount] => 0
[type] => 0
[id] => 206570
[subTeams] => Array
(
)
[teamColors] => stdClass Object
(
[primary] => #52b030
[secondary] => #52b030
[text] => #ffffff
)
)
[122366] => stdClass Object
(
[name] => Tsitsipas S.
[slug] => tsitsipas-stefanos
[shortName] => Tsitsipas S.
[userCount] => 0
[type] => 0
[id] => 122366
[subTeams] => Array
(
)
[teamColors] => stdClass Object
(
[primary] => #52b030
[secondary] => #52b030
[text] => #ffffff
)
)
[homeScore] => stdClass Object
(
)
[awayScore] => stdClass Object
(
)
[time] => stdClass Object
(
)
[changes] => stdClass Object
(
[changeTimestamp] => 0
)
[hasGlobalHighlights] =>
[id] => 9486886
[startTimestamp] => 1619263800
[slug] => sinner-tsitsipas
[periods] => stdClass Object
(
[point] => Game
[current] => Match
[period1] => 1st set
[period2] => 2nd set
[period3] => 3rd set
[period4] => 4th set
[period5] => 5th set
)
[finalResultOnly] =>
Очень надеюсь что нигде не ошибся при составлении массивов.
Туплю немного и не понимаю, как все это сделать.
Код, попытки что либо сделать, дальше не понимаю куда двигаться. За ранее спасибо и извиняюсь.
$date = date("Y-m-d");
$allmatches = file_get_contents("allmatches/$date.txt");
$allmatches = json_decode($allmatches);
$path = scandir("allteams/$date");
foreach ($allmatches->events as $arrAllMatches){
if($arrAllMatches->status->type == 'notstarted' && empty($arrAllMatches->homeTeam->subTeams) && empty($arrAllMatches->awayTeam->subTeams)){
$matches[$arrAllMatches->tournament->id] =
$arrAllMatches;
}
}