Good day to all. Something I can not figure out how to do this rounding.

Tried to do a check on the remainder of the division (%), if it is equal to 0. then further with the help of ceil () round up. It turns out not what you need :)

if (($val_get % $pack_val) == 0) $val_get = ceil($val_get/$pack_val); else $val_get = $pack_val; 

Here is what I wrote. It is necessary to provide the case that if $pack_val > $val_get . The remainder is obtained equal to $val_get in case $pack_val > $val_get . Help me please :)

    1 answer 1

    What is $ pack_val and $ val_get - do not understand.

     //$base - число, кратно которому округляем. //$num - вводимое число if($base>0){ return ceil($num/$base)*$base; }else{ return 0; } 
    • if ($ val_get% $ pack_val! = 0) $ val_get = ($ val_get - $ val_get% $ pack_val) + $ pack_val; else $ val_get = $ pack_val; I came up with this option) Inet dumped and could not write - SnowMan