3v4l.org

run code in 300+ PHP versions simultaneously
<?php function SplitIntoGroups($array) { $toReturnArray = array(); $currentNumber = $array[0]; $currentCount = 1; for($i=1; $i <= count($array); $i++) { if($array[$i] == $currentNumber) { $currentCount++; } else { $toReturnArray[] = array($currentNumber, $currentCount); $currentNumber = $array[$i]; $currentCount = 1; } } return $toReturnArray; } $answer = SplitIntoGroups(array(1,1,1,2,2,3,3,1,1,2,2,3)); for($i=0; $i<count($answer); $i++) { echo '[' . $answer[$i][0] . '] = ' . $answer[$i][1] . '<br />'; }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 12 in /in/NjqGF on line 9 Warning: Undefined array key 12 in /in/NjqGF on line 16 [1] = 3<br />[2] = 2<br />[3] = 2<br />[1] = 2<br />[2] = 2<br />[3] = 1<br />

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:
72.88 ms | 401 KiB | 8 Q