3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundDownToHalf($number) { $remainder = ($number * 10) % 10; $half = $remainder >= 5 ? 0.5 : 0; $value = floatval(intval($number) + $half); return number_format($value, 1, '.', ''); } print roundDownToHalf(4.9) . "\n"; print roundDownToHalf(4.8) . "\n"; print roundDownToHalf(4.5) . "\n"; print roundDownToHalf(3.8) . "\n"; print roundDownToHalf(2.3) . "\n"; print roundDownToHalf(1.0) . "\n"; ?>
Output for git.master, git.master_jit, rfc.property-hooks
4.5 4.5 4.5 3.5 2.0 1.0

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