3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = range(0,1000); function closest($arr, $x) { $result = "default"; sort($arr); foreach($arr as $value) { if($value < $x) { $result = $value; } else break; } return $result; } echo closest($arr,17)."\n"; echo closest($arr,20)."\n"; echo closest($arr,6);
based on ka9rF
Output for 5.3.19 - 5.6.38, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.2.11
16 19 5