3v4l.org

run code in 300+ PHP versions simultaneously
<?php function append(array $init, array $add, $key = null) { $_init = $init; if (is_null($key)) { $_init[] = $add; return array_merge($_init, $init); } else { $_init[$key] = $add; return [ $key => array_merge($_init[$key], $init[$key]) ]; } } $a = [ 'phone' => [ 'code' => '+38', ], ]; $b = [ 'prefix' => '095', 'number' => '7700418', ]; var_dump(append($a, $b, 'phone')); $a = [ 'code' => '+38', ]; $b = [ 'prefix' => '095', 'number' => '7700418', ]; var_dump(append($a, $b));
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["phone"]=> array(3) { ["prefix"]=> string(3) "095" ["number"]=> string(7) "7700418" ["code"]=> string(3) "+38" } } array(2) { ["code"]=> string(3) "+38" [0]=> array(2) { ["prefix"]=> string(3) "095" ["number"]=> string(7) "7700418" } }

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