3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toValid($var) { return strtotime(str_replace('.', ':', sprintf('%.2f', $var))); } function getNearest($arr, $var) { $var = toValid($var); $arr = array_map('toValid', $arr); usort($arr, function($a, $b) use ($var) { return abs($a - $var) - abs($b - $var); }); return array_shift($arr); } echo date('H.i', getNearest([14.49,17.57,12.30,19.22], '13.30'));
Output for git.master_jit, git.master, rfc.property-hooks
12.30

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