Round DOWN to nearest 50000 ?

Posted on 2006-07-18
Last Modified: 2013-12-12
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;

Question by:msiedle
LVL 35

Accepted Solution

Raynard7 earned 500 total points
ID: 17135501
If you are rounding down - you can just subtract the remainder from a modular division

$roundFigure = 5000;
$input = 35001;

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

Which should give


Author Comment

ID: 17135554
Beautiful! Thank you :-)


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
website maintenance mode 1 25
PHP not parsing ' character 12 46
Doing something wrong with this PDO Select Statement... 3 18
JQuery Search Filter 2 28
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question