3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = range(0,1000); function find_closest($arr,$x){ sort($arr); $filtered_array = array_filter($arr,function($v)use($x){ return $v < $x; }); return count($filtered_array) > 0 ? end($filtered_array) : "Your Message"; } echo find_closest($arr,17)."\n"; echo find_closest($arr,20)."\n"; echo find_closest($arr,6);
based on aSCHj
Output for 5.3.19 - 7.2.8
16 19 5