3v4l.org

run code in 300+ PHP versions simultaneously
<?php $poorly_merged = [ (object)["id" => "5", "unit" => 1], (object)["id" => "3", "text" => "three"], (object)["id" => "1", "text" => "one"], (object)["id" => "2", "text" => "two"], (object)["id" => "4", "text" => "four"], (object)["id" => "5", "text" => "five"], (object)["id" => "3", "unit" => 0], (object)["id" => "1", "unit" => "0"], (object)["id" => "2", "unit" => 0], (object)["id" => "4", "unit" => "0"] ]; $output = []; foreach ($poorly_merged as $object) { if (!isset($output[$object->id])) { $output[$object->id] = $object; } else { foreach ($object as $property => $value) { $output[$object->id]->{$property} = $value; } } } ksort($output); // optionally order by ids var_export(array_values($output));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => (object) array( 'id' => '1', 'text' => 'one', 'unit' => '0', ), 1 => (object) array( 'id' => '2', 'text' => 'two', 'unit' => 0, ), 2 => (object) array( 'id' => '3', 'text' => 'three', 'unit' => 0, ), 3 => (object) array( 'id' => '4', 'text' => 'four', 'unit' => '0', ), 4 => (object) array( 'id' => '5', 'unit' => 1, 'text' => 'five', ), )

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