我想这应该很简单,但我已经坚持了一段时间,所以我需要帮助。我有一个 cakephp 应用程序,我得到以下数组:
chratSortedMean= array(
'totalAucFourHour' => array(
'Screening Visit-1 (scr)' => array(
'MmttFourthHour' => array(
'totalAucs' => array(
(int) 0 => (float) 0,
(int) 1 => (float) 220
)
)
),
'Month12' => array(
'MmttFourthHour' => array(
'totalAucs' => array(
(int) 0 => (float) 263.25,
(int) 1 => (float) 16.25
)
)
)
),
'totalAucTwoHour' => array(
'Day0' => array(
'MmttSecondHour' => array(
'totalAucs' => array(
(int) 0 => (float) 0,
(int) 1 => (float) 112.125
)
)
),
'DayD2' => array(
'MmttSecondHour' => array(
'totalAucs' => array(
(int) 0 => (float) 97.375,
(int) 1 => (float) 4.5
)
)
),
'Month3' => array(
'MmttSecondHour' => array(
'totalAucs' => array(
(int) 0 => (float) 8.53125,
(int) 1 => (float) 8.75
)
)
)
)
)
我想分别为 totalAucFourHour 和 totalAucTwoHour 分别计算每个时间点(Screening Visit-1 (scr)、Month12、Day0 等)的 totalAucs 值的平均值。
所以我想要的结果有点如下形式:
'totalAucFourHour' => array(
'Screening Visit-1 (scr)' => array(
'MmttFourthHour' => array(
'totalAucMean' => (float) 110
)
)
),
'Month12' => array(
'MmttFourthHour' => array(
'totalAucMean' => (float) 139.75
)
)
)
),
等等。我不想使用多个 for 循环,因为我希望数据在未来会增长。