Jump to content

round up to 10


jwk811

Recommended Posts

I dont think that function works.

Im pretty sure these do..

 

<?php

$num = 123;

function round_up_ten($num)
{
$mod = $num % 10;
$add = 10 - $mod;
$num += $add;
echo $num;
}

function round_dwn_ten($num)
{
$mod = $num % 10;
$add = 10 - (10 - $mod);
$num -= $add;
echo $num;
}

round_up_ten($num); // Should be 130
round_dwn_ten($num); // Should be 120
?>

Link to comment
https://forums.phpfreaks.com/topic/39119-round-up-to-10/#findComment-188440
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.