0

How Can I Calculate Sum of below 02 arrays in php? I need key as same.

This is the first and second array

   $array1 = [
        1 => 0
        2 => 0
        3 => 0
        4 => 10
        5 => 54
        6 => 0
        7 => 0
        8 => 0
   ];

$array2 = [
        1 => 0
        2 => 0
        3 => 100
        4 => 110
        5 => 54
        6 => 08
        7 => 0
        8 => 0
   ];

The Total array should be as follow

$total = [
        1 => 0
        2 => 0
        3 => 100
        4 => 120
        5 => 108
        6 => 08
        7 => 0
        8 => 0
   ];
Anushka Deshan
  • 81
  • 4
  • 14

0 Answers0