0

I have a questions to decrease or increase decimal value in my PHP. For example I have 2573000.00 I want to make it 2500000.00. I have tried to use round() but not give me best answer. How to do that ?

Thank you.

Antonio
  • 755
  • 4
  • 14
  • 35
  • [Round to max thousand, hundred etc in PHP](https://stackoverflow.com/a/43932669/6521116) – LF00 Jun 20 '17 at 04:28
  • [php round 2e decimal to 0 or 5](https://stackoverflow.com/a/40783574/6521116) – LF00 Jun 20 '17 at 04:29
  • You will need to give more explanation, it's not at all clear what you want. Do you always want to floor the value starting at the 6th decimal to the left of the decimal? When do you want to increase? – Spencer Wieczorek Jun 20 '17 at 04:30
  • @KrisRoofe If I use that reference I will got **2580000** not **2500000** – Antonio Jun 20 '17 at 04:31
  • @Antonio Perhaps if you actually explain your question you can get better answers. We can certainly give you an answer that will convert `2573000.00` to `2500000.00`, but you never stated what functionality you are looking for. If you want to only **decrease** then don't mention **increase**. – Spencer Wieczorek Jun 20 '17 at 04:38
  • This is done I've got the answer below. @SpencerWieczorek – Antonio Jun 20 '17 at 04:40
  • @Antonio That doesn't change the fact that this question is unclear, you never stated what functionality you are looking for. It's great you got what your looking for, but future visitors won't understand your question. – Spencer Wieczorek Jun 20 '17 at 04:43

1 Answers1

0

Try this:

$a = 2573000.00;
$b = (int)($a / 100000) * 100000;
echo $b;
Pang
  • 9,564
  • 146
  • 81
  • 122
PHP Geek
  • 3,949
  • 1
  • 16
  • 32