3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $result = array(); $arrayOne = array(array("a" => 30, "b" => 5), array("a" => 30, "b" => 5), array("a" => 30, "b" => 0), array("a" => 5, "b" => 5), array("a" => 15, "b" => 0)); $arrayTwo = array(array("a" => 207, "b" => 225), array("a" => 35, "b" => 0), array("a" => 35, "b" => 90), array("a" => 80, "b" => 140), array("a" => 40, "b" => 35)); foreach($arrayOne as $key => $value) { $result[] = array( "a" => $value["a"] + $arrayTwo[$key]["a"], "b" => $value["b"] + $arrayTwo[$key]["b"] ); } print_r($result);
Output for 4.3.0 - 7.1.0
Array ( [0] => Array ( [a] => 237 [b] => 230 ) [1] => Array ( [a] => 65 [b] => 5 ) [2] => Array ( [a] => 65 [b] => 90 ) [3] => Array ( [a] => 85 [b] => 145 ) [4] => Array ( [a] => 55 [b] => 35 ) )