1
Hello,
I have values like 1,000,000 that I need to add and then display. I’m doing this:
<?php
$vlgastoGeralDeFabricacao = str_replace(',', '.', $vlgastoGeralDeFabricacao);
$vlDepreciacao = str_replace(',', '.', $vlDepreciacao);
$vlgastoPessoalDeProducao = str_replace(',', '.', $vlgastoPessoalDeProducao);
$vlOutrosCustosIndiretos = str_replace(',', '.', $vlOutrosCustosIndiretos);
$custoIndireto = $vlgastoGeralDeFabricacao + $vlDepreciacao + $vlgastoPessoalDeProducao + $vlOutrosCustosIndiretos;
echo number_format($custoIndireto,2,',','.');
?>
but that mistake always appears:
Notice: A non well Formed Numeric value encountered
and points to the echo line.
Besides that the value of 185.700,00 is appearing as 185,70
$vlgastoGeralDeFabricacao
what is the initial value?– novic
The value is 185.700,00
– GustavoSevero
You mean, what is the amount of $cost? It’s supposed to be 804,230.00
– GustavoSevero
before running this line
$vlgastoGeralDeFabricacao = str_replace(',', '.', $vlgastoGeralDeFabricacao);´ qual é valor de
$vlgastoGeralDeabricacao`?– novic
The value is what I informed above @Virgilionovic, 185.700,00
– GustavoSevero
These values are taken from a form.
– GustavoSevero
So you can come like this:
1.000,00
?– novic
No, because that way 1,000.00 is not added up, php does not compute monetary values with "," comma.
– GustavoSevero
Let’s go continue this discussion in chat.
– novic
Try this way; add all numbers (without using
str_replace
) and then show off with thenumber_format
and see what comes up.– RFL