3v4l.org

run code in 300+ PHP versions simultaneously
<?php $intervals = [ [1, 2], [2, 2], [5, 6], [8, 10], ]; $rr = []; foreach($intervals as $v){ $rr[] = range($v[0],$v[1]); } $n = 10; $range = range(1,$n); $diff = array_diff($range,array_values(array_unique(array_merge(...$rr)))); $r = groupConsecutive($diff); echo '<pre>'; print_r($r); function groupConsecutive($array) { $ret = array(); $temp = array(); foreach($array as $val) { if(next($array) == ($val + 1)) $temp[] = $val; else if(count($temp) > 0) { $temp[] = $val; $ret[] = $temp; $temp = array(); } else $ret[] = $val; } return $ret; }
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [0] => 3 [1] => 4 ) [1] => 7 )

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:
143.38 ms | 405 KiB | 5 Q