Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

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
0
msiedle
Asked:
msiedle
1 Solution
 
Raynard7Commented:
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now