$s = Array (0 = = Array (0 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' bea01-120n ', ' type ') = ' bea01-120n ', 2 = 176, ' count ' = 176, 1 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' bea21-110n ', ' type ' = ' bea21-110n ', 2 = 1056, ' count ' = 1056, '), 1 = = Array (0 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' bea01-120n ', ' type ' = ' bea01-120n ', 2 = 192, ' count ' = 192,), 1 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' bea21-110n ', ' type ' = ' bea21-110n ', 2 = 960, ' count ' = 960,),),
A subtotal of the type entry for which the type corresponds to the difference and $s[0] and $s[1]. (Subtotal has been implemented, with unset)
The ideal result:
Subtotal results: bea01-120n 176 bea01-120n 192 Difference Value: 176-192 = 16
bea21-110n 1056 bea21-110n 960 1056-960 = 96
Subtotal: 176+1056=1232 192+960 = 1152
Reply to discussion (solution)
$s = Array (0 = = Array (0 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' BEA01 -120n ', ' type ' = ' bea01-120n ', 2 = 176, ' count ' = 176, 1 = = Array (0 = ' 2014-04-11 ') , ' time ' = ' 2014-04-11 ', 1 = ' bea21-110n ', ' type ' = ' bea21-110n ', 2 = 1056, ' count ' = 1056, ), 1 = = Array (0 = = Array (0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ', 1 = ' bea01-12 0N ', ' type ' = ' bea01-120n ', 2 = 192, ' count ' = 192, 1 = = Array (0 = ' 2014-04-11 ', ' Time ' = ' 2014-04-11 ', 1 = ' bea21-110n ', ' type ' = ' bea21-110n ', 2 = 960, ' count ' = 960, ), function foo ($a, $b) {for ($i =0; $i
Array ( [0] = = Array ( [0] = = bea01-120n [1] = -16 ) [1] = = Array ( [0] = > bea21-110n [1] = +) )
Subtotal, you've done it, and I'm slacking off.
$s = Array (
0 = Array (
0 = Array (
0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ',
1 = ' bea01-120n ', ' type ' = ' bea01-120n ',
2 = 176, ' count ' = 176,
),
1 = Array (
0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ',
1 = ' bea21-110n ', ' type ' = ' bea21-110n ',
2 = 1056, ' count ' = 1056,
),
),
1 = Array (
0 = Array (
0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ',
1 = ' bea01-120n ', ' type ' = ' bea01-120n ',
2 = 192, ' count ' = 192,
),
1 = Array (
0 = ' 2014-04-11 ', ' time ' = ' 2014-04-11 ',
1 = ' bea21-110n ', ' type ' = ' bea21-110n ',
2 = 960, ' count ' = 960,
),
),
);
function my ($a, $b) {
foreach ($a as $k = = $v) {
echo $a [$k] [' count ']-$b [$k] [' count ']. "
";
}
}
Call_user_func_array (' my ', $s);