3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array =[203,204,204,203,203,205]; $i=-1; $prev = null; $new=[]; Foreach($array as $val){ If($val != $prev){ $i++; } if(!isset($new[$i][$val])){ $new[$i][$val] =1; }else{ $new[$i][$val]++; } $prev = $val; } var_dump($new);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(1) { [203]=> int(1) } [1]=> array(1) { [204]=> int(2) } [2]=> array(1) { [203]=> int(2) } [3]=> array(1) { [205]=> int(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:
128.35 ms | 406 KiB | 5 Q