Sum

mail@pastecode.io avatar
unknown
php
2 years ago
512 B
8
Indexable
<?php
    $matris1 = [
        [1,  2,  3,  4],
        [5,  6,  7,  8],
        [9, 10, 11, 12],
        [13, 14, 15, 16]

    ];
    $matris2 = [
        [1,  2,  3,  4],
        [5,  6,  7,  8],
        [9, 10, 11, 12],
        [13, 14, 15, 16]

    ];
    $sum = null;
    for($i=0 ; $i < count($matris1); $i++ ){
        for( $j = 0 ; $j < count($matris1[$i]) ; $j++){
            $sum[$i][$j] = $matris1 [$i][$j] + $matris2 [$i][$j] ; 
        }
    }

    print_r($sum);
    ?>