Round up a number to a multiple of a certain number

Good afternoon everyone. I can’t figure out how to do this rounding.

I tried to check for the remainder of the division (%), if it is equal to 0. then using ceil() we 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’s what I wrote. We need to provide for the case that if $pack_val > $val_get. The remainder is equal to $val_getif $pack_val > $val_get. Please help 🙂


Answer 1, authority 100%

I don’t understand what is $pack_val and $val_get.

//$base - ,   .
//$num -      
if($base>0){
  return ceil($num/$base)*$base;
}else{
  return 0;
}