3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['A' => 'O', 'B' => 'O', 'C' => 1, 'count' => 1], ['A' => 'Test', 'B' => 'Test', 'C' => 1, 'count' => 1], ['A' => 'O', 'B' => 'O', 'C' => 1, 'count' => 1], ['A' => 'Test', 'B' => 'Test', 'C' => 1, 'count' => 1], ['A' => 'Test', 'B' => 'test1', 'C' => 2, 'count' => 1], ]; $result = []; foreach ($array as $row) { $key = implode('~', array_slice($row, 0, 3)); if (!isset($result[$key])) { $result[$key] = $row; } else { $result[$key]['count'] += $row['count']; } } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'A' => 'O', 'B' => 'O', 'C' => 1, 'count' => 2, ), 1 => array ( 'A' => 'Test', 'B' => 'Test', 'C' => 1, 'count' => 2, ), 2 => array ( 'A' => 'Test', 'B' => 'test1', 'C' => 2, 'count' => 1, ), )

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