/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function roundnum ($num, $nearest) { $ret = 0; $mod = $num % $nearest; if ($mod >= 0) $ret = ( $mod > ( $nearest / 2)) ? $num + ( $nearest - $mod) : $num - $mod; else $ret = ( $mod > (-$nearest / 2)) ? $num - $mod : $num + ( -$nearest - $mod); return $ret; }