3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['task_id' => 1, 'name' => 'do dishes', 'user' => 'bob'], ['task_id' => 1, 'name' => 'do dishes', 'user' => 'liam'], ['task_id' => 2, 'name' => 'vacuum', 'user' => 'liam'], ['task_id' => 3, 'name' => 'Take out thrash', 'user' => 'liam'], ['task_id' => 3, 'name' => 'Take out thrash', 'user' => 'bob'], ]; $result = []; foreach ($array as $row) { extract($row); if (!isset($ref[$task_id])) { $ref[$task_id] = ['task_id' => $task_id, 'name' => $name, 'users' => []]; $result[] =& $ref[$task_id]; } $ref[$task_id]['users'][] = $user; } var_export($result);
Output for git.master_jit, git.master
array ( 0 => array ( 'task_id' => 1, 'name' => 'do dishes', 'users' => array ( 0 => 'bob', 1 => 'liam', ), ), 1 => array ( 'task_id' => 2, 'name' => 'vacuum', 'users' => array ( 0 => 'liam', ), ), 2 => array ( 'task_id' => 3, 'name' => 'Take out thrash', 'users' => array ( 0 => 'liam', 1 => 'bob', ), ), )

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