3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 1650 => ["firstName" => "jack", "lastName" => "straw"], 1649 => ["firstName" => "jack", "lastName" => "straw"], 1651 => ["firstName" => "jack", "lastName" => "straw"], 1652 => ["firstName" => "jack", "lastName" => "straw"], 1653 => ["firstName" => "jack1", "lastName" => "straw"], 1654 => ["firstName" => "jack1", "lastName" => "straw"] ]; ksort($array); $temp = []; foreach ($array as $key => $row) { $compositeKey = $row['firstName'] . '-' . $row['firstName']; $temp[$compositeKey] ??= $row; $temp[$compositeKey]['mergedWith'][] = $key; } $result = []; foreach ($temp as $row) { $result[array_shift($row['mergedWith'])] = $row; } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 1649 => array ( 'firstName' => 'jack', 'lastName' => 'straw', 'mergedWith' => array ( 0 => 1650, 1 => 1651, 2 => 1652, ), ), 1653 => array ( 'firstName' => 'jack1', 'lastName' => 'straw', 'mergedWith' => array ( 0 => 1654, ), ), )

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