View Full Version : Rounding a variable
danielwarner
12-18-2006, 10:05 PM
Is is possible to round a variable to the nearest 250 but always round up? so for example 1-250 = 250 251-500 = 500 etc...
Thanks.
<?php
$nums = array(40,250,300,520);
foreach($nums as $num) {
$rounded = ceil($num/250)*250;
echo $num.'=>'.$rounded."\n";
}
?>
outputs:
40=>250
250=>250
300=>500
520=>750
that what you're after?
danielwarner
12-18-2006, 11:34 PM
wow thanks thats fantastic...i can modify the rest!
:D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.