3v4l.org

run code in 300+ PHP versions simultaneously
<?php $color = [ ['id' => 1, 'color' => 'red'], ['id' => 2, 'color' => 'green'], ['id' => 3, 'color' => 'blue'], ]; $size = [ ['id' => 1, 'size' => 'SM'], ['id' => 2, 'size' => 'XL'], ['id' => 4, 'size' => 'LG'], ['id' => 3, 'size' => 'MD'], ]; foreach(array_merge($color, $size) as $el){ $merged[$el['id']] = ($merged[$el['id']] ?? []) + $el; } var_export($merged);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 1 => array ( 'id' => 1, 'color' => 'red', 'size' => 'SM', ), 2 => array ( 'id' => 2, 'color' => 'green', 'size' => 'XL', ), 3 => array ( 'id' => 3, 'color' => 'blue', 'size' => 'MD', ), 4 => array ( 'id' => 4, 'size' => 'LG', ), )

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:
162.54 ms | 406 KiB | 5 Q