Round DOWN to nearest 50000 ?

Hi all

I need to be able to round down a number to the nearest 50000 ...any ideas on how to do this? Are there any existing php functions that can handle this? It's a bit beyond the round() functions isn't it?

Example 1:
$input = 35001;
$output needs to be 350000;

Example 2:
$input = 34999;
$output needs to be 300000;

Cheers,
Mark
LVL 2
msiedleAsked:
Who is Participating?
 
Raynard7Connect With a Mentor Commented:
If you are rounding down - you can just subtract the remainder from a modular division

ie
$roundFigure = 5000;
$input = 35001;

$output = $input - fmod ($input, $roundFigure;

Which should give

35000
0
 
msiedleAuthor Commented:
Beautiful! Thank you :-)

M
0
All Courses

From novice to tech pro — start learning today.