[ create a new paste ] login | about

Link: http://codepad.org/DIF4bELg    [ raw code | output | fork ]

PHP, pasted on Jun 21:
<?php

$months = Array ( "may" =>
            Array (
                "A" => 101,
                "B" => 33,
                "C" => 25
            ),
        "june" =>
            Array (
                "A" => 73,
                "B" => 11,
                "D" => 32
            ),
        "july" =>
            Array (
                "A" => 45,
                "C" => 12
            )
        );

foreach ($months as $month) {
    foreach ($month as $letter => $value) {
        if (isset($months['all'][$letter])) {
            $months['all'][$letter] += $value;
        } else {
            $months['all'][$letter] = $value;
        }
    }
}
print_r($months['all']);


Output:
1
2
3
4
5
6
7
Array
(
    [A] => 219
    [B] => 44
    [C] => 37
    [D] => 32
)


Create a new paste based on this one


Comments: