3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['45', '21', '45', '45', '45', '29', '35', '35', '21']; $result = []; $last = null; foreach ($array as $v) { if ($last !== $v) { unset($ref); $result[] =& $ref; } $ref[] = $v; $last = $v; } var_export($result);
Output for git.master, git.master_jit
array ( 0 => array ( 0 => '45', ), 1 => array ( 0 => '21', ), 2 => array ( 0 => '45', 1 => '45', 2 => '45', ), 3 => array ( 0 => '29', ), 4 => array ( 0 => '35', 1 => '35', ), 5 => array ( 0 => '21', ), )

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