3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbs = [1,2,50.2,5.43,1.22,1.9,10.999,-20.5,-15.8,-2.75]; foreach($numbs as $num) { $mod = $num < 0 ? -1 : 1; $absNum = abs($num); if($absNum >= ((int) $absNum) + 0.75) { // Round Up $roundedNum = ceil($absNum) * $mod; } else { //Round Down $roundedNum = floor($absNum) * $mod; } echo $num . ' Rounded to ' . $roundedNum . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
1 Rounded to 1 2 Rounded to 2 50.2 Rounded to 50 5.43 Rounded to 5 1.22 Rounded to 1 1.9 Rounded to 2 10.999 Rounded to 11 -20.5 Rounded to -20 -15.8 Rounded to -16 -2.75 Rounded to -3

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