Solved

Round DOWN to nearest 50000 ?

Posted on 2006-07-18
2
645 Views
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;

Cheers,
Mark
0
Comment
Question by:msiedle
2 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
Comment Utility
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
 
LVL 2

Author Comment

by:msiedle
Comment Utility
Beautiful! Thank you :-)

M
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now