3v4l.org

run code in 300+ PHP versions simultaneously
<?php function removeDuplicates($array){ $freq = 5; $result = []; $size = count($array); $counts = []; for($i=0;$i<$size;++$i) $counts[] = 0; $counts[$size-1] = 1; for($i=$size-2;$i>=0;--$i){ $counts[$i] = 1; if($array[$i] === $array[$i+1]) $counts[$i] = $counts[$i+1] + 1; } for($i=0;$i<$size;++$i){ $result[] = $array[$i]; if($counts[$i] >= $freq){ $i += $counts[$i] - 1; } } return $result; } $array = array(1,2,4,1,1,1,1,0,8,7,2,0,0,8,8,8,8,8,8,8,2,4,1,5); print_r(removeDuplicates($array));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 0 [8] => 8 [9] => 7 [10] => 2 [11] => 0 [12] => 0 [13] => 8 [14] => 2 [15] => 4 [16] => 1 [17] => 5 )

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