<?php
$t1 = array (
"basicInfo" => array (
"The Sineps",
"December 25, 2010",
"lemonpole"
),
"overallRecord" => array (
0,
0,
0,
0
),
"overallSeasons" => array (
"season1.cs" => array (0, 0, 0),
"season2.cs" => array (0, 0, 0)
),
"matches" => array (
"season1.cs" => array (
"week1" => array ("12", "3", "1"),
"week2" => array ("8", "8" ,"0"),
"week3" => array ("8", "8" ,"0")
),
"season2.cs" => array (
"week1" => array ("9", "2", "5"),
"week2" => array ("12", "2" ,"2")
)
)
);
foreach ($t1['matches'] as $season => $weeks) {
$t1['overallSeasons'][$season] = array_map(
fn(...$col) => array_sum($col),
...array_values($t1['matches'][$season])
);
}
var_export($t1);
preferences:
24.68 ms | 407 KiB | 5 Q