3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array( 'foo' => 1, 'bar' => 2, 'thing' => 'apple' ), array( 'foo' => 1, 'bar' => 2, 'thing' => 'orange' ), array( 'foo' => 2, 'bar' => 2, 'thing' => 'apple' ), ); $newArr = $keys = array(); foreach ($arr as $row) { if (isset($keys[$row['foo']][$row['bar']])) { $newArr[$keys[$row['foo']][$row['bar']]]['thing'][] = $row['thing']; } else { $keys[$row['foo']][$row['bar']] = array_push($newArr, $row) - 1; $newArr[$keys[$row['foo']][$row['bar']]]['thing'] = array($row['thing']); } } unset($keys); print_r($newArr);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [0] => Array ( [foo] => 1 [bar] => 2 [thing] => Array ( [0] => apple [1] => orange ) ) [1] => Array ( [foo] => 2 [bar] => 2 [thing] => Array ( [0] => apple ) ) )

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