3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $l = array_fill(0, 25, ''); function clamp($n) { return ($n > 3) ? 3 : $n; } foreach($l as $i=>$b) { echo $i . ' => ' . clamp($i) . "\n"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
0 => 0 1 => 1 2 => 2 3 => 3 4 => 3 5 => 3 6 => 3 7 => 3 8 => 3 9 => 3 10 => 3 11 => 3 12 => 3 13 => 3 14 => 3 15 => 3 16 => 3 17 => 3 18 => 3 19 => 3 20 => 3 21 => 3 22 => 3 23 => 3 24 => 3