3v4l.org

run code in 300+ PHP versions simultaneously
<?php function contains($start, $end, $check) { return $check > $start && $check < $end; } function overlap($a, $b) { return contains($a[0], $a[1], $b[0]) || contains($a[0], $a[1], $b[1]); } function checkListForOverlaps($list) { for($i=0,$c=count($list); $i<$c; ++$i) { for($j=$i+1; $j<$c; ++$j) { if( overlap($list[$i], $list[$j]) ) { printf("%s and %s overlap\n", json_encode($list[$i]), json_encode($list[$j])); } } } } $input = [[1, 3],[3, 7],[9,INF], [2, 5]]; checkListForOverlaps($input);

preferences:
27.82 ms | 402 KiB | 5 Q