<?php
$A = array(
'A'=>array('a'=>array(
'v1'=>1
'v2'=>2
'v3'=>3
),
'b'=>array(
'v1'=>1
'v2'=>2
'v3'=>3
)
),
'B'=>array('a'=>array(
'v1'=>1
'v2'=>2
'v3'=>3
),
'b'=>array(
'v1'=>1
'v2'=>2
'v3'=>3
)
),
...
);
=>$total= array('a'=>array(
'v1'=>2
'v2'=>4
'v3'=>6
),
'b'=>array(
'v1'=>2
'v2'=>4
'v3'=>6
?>
それは機能しますが、一般的な方法ではありません。
$total_av1 = $A['A']['a']['v1'] + $A['B']['a']['v1'];
$total_av2 = $A['A']['a']['v2'] + $A['B']['a']['v2'];
$total_av3 = $A['A']['a']['v3'] + $A['B']['a']['v3'];
$total_bv1 = $A['A']['b']['v1'] + $A['B']['b']['v1'];
$total_bv2 = $A['A']['b']['v2'] + $A['B']['b']['v2'];
$total_bv3 = $A['A']['b']['v3'] + $A['B']['b']['v3'];
$total = array(
"a"=>array($total_av1,$total_av2,$total_av3),
"b"=>array($total_bv1,$total_bv2,$total_bv3)
);
echo '<pre>';
print_r($A);
print_r($total);
echo '</pre>';