3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array(1105,2140,3170,1000,1500,1501); $start = 1000; $end = 1500; $start_index = -1; sort($numbers); $low = 0; $high = count($numbers) - 1; while($low <= $high){ $mid = intval(($low + $high) / 2); if($numbers[$mid] > $end){ $high = $mid - 1; }else if($numbers[$mid] < $start){ $low = $mid + 1; }else{ $start_index = $mid; $high = $mid - 1; } } $result = []; for($i = $start_index; $i < count($numbers); ++$i){ if($numbers[$i] > $end) break; $result[] = $numbers[$i]; } print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 1000 [1] => 1105 [2] => 1500 )

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