3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ["id" => 1, "begin" => "01/01", "diagnostic" => "a"], ["id" => 1, "begin" => "01/01", "diagnostic" => "b"], ["id" => 1, "begin" => "01/01", "diagnostic" => ""], ["id" => 1, "begin" => "02/02", "diagnostic" => "a"], ]; $result = []; foreach ($data as $row) { $compositeKey = $row['id'] . '-' . $row['begin']; if (!isset($result[$compositeKey])) { $result[$compositeKey] = $row; } elseif (strlen($row['diagnostic'])) { $result[$compositeKey]['diagnostic'] .= (strlen($result[$compositeKey]['diagnostic']) ? ', ' : '') . $row['diagnostic']; } } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 1, 'begin' => '01/01', 'diagnostic' => 'a, b', ), 1 => array ( 'id' => 1, 'begin' => '02/02', 'diagnostic' => 'a', ), )

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:
147.74 ms | 405 KiB | 5 Q