3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 1649 => ["firstName" => "jack", "lastName" => "straw"], 1650 => ["firstName" => "jack", "lastName" => "straw"], 1651 => ["firstName" => "jack", "lastName" => "straw"], 1652 => ["firstName" => "jack", "lastName" => "straw"], 1653 => ["firstName" => "jack1", "lastName" => "straw"], 1654 => ["firstName" => "jack1", "lastName" => "straw"] ]; foreach ($array as $key => &$row) { $compositeKey = $row['firstName'] . '-' . $row['firstName']; if (!isset($ref[$compositeKey])) { $ref[$compositeKey] = &$row; } else { $ref[$compositeKey]['mergedWith'][] = $key; unset($array[$key]); } } var_export($array);
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:
26.9 ms | 406 KiB | 5 Q