3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ "A" => "dataA1", "B" => "dataB1", "C" => "dataC1"]; $arr2 = [ "A" => "dataA2", "C" => "dataC2", "D" => "dataD2"]; $out = array_reduce( array_unique(array_merge(array_keys($arr1), array_keys($arr2))), function($c, $k) use($arr1, $arr2) { $c[$k] = array_merge( [$arr1[$k] ?? null], [$arr2[$k] ?? null], ); return $c; }, [] ); var_dump($out);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { ["A"]=> array(2) { [0]=> string(6) "dataA1" [1]=> string(6) "dataA2" } ["B"]=> array(2) { [0]=> string(6) "dataB1" [1]=> NULL } ["C"]=> array(2) { [0]=> string(6) "dataC1" [1]=> string(6) "dataC2" } ["D"]=> array(2) { [0]=> NULL [1]=> string(6) "dataD2" } }

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:
56.01 ms | 402 KiB | 8 Q