3v4l.org

run code in 300+ PHP versions simultaneously
<?php $r1 = [ 1 => [1, 2, "one"], 2 => [5, 5, "two"], ]; $r2 = [ 1 => [null, 20, "one"], 2 => [1, 0, "two"], ]; $sum = function (array $a1, array $a2) { return array_map( function($e1) { return (is_int($e1) || is_null($e1)) ? array_sum(func_get_args()) : $e1; }, $a1, $a2 ); }; $res = []; foreach ($r1 as $k => $a) { $res[$k] = $sum($r1[$k], $r2[$k]); } var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [1]=> array(3) { [0]=> int(1) [1]=> int(22) [2]=> string(3) "one" } [2]=> array(3) { [0]=> int(6) [1]=> int(5) [2]=> string(3) "two" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
170.06 ms | 406 KiB | 5 Q