2
I need to divide the value 6999,99 by 3, but when dividing it returns 2333,00 ie does not return the cents, follows a hypothetical example:
$parcelas = 3;
$valor = double(6.999,99); //já usei com e sem double e na mesma
$valorTotal = number_format($valor, 2, '.', '');
$valor_parcela = $valorTotal / $parcelas;
echo 'R$'. number_format($valor_parcela, 2, ',', '.');
The value already comes formatted from the input with a javascript mask, if I pass the value this way 6999.99, it is printed correctly. Thank you
error is on that line
$valor = double(6.999,99);
should be$valor = 6999.99;
– novic
@Virgilionovic I’ve done this way too but it didn’t work the only way it works is by passing the value so 6999.99 if you put the (comma) it gives error in variable Parse error: syntax error, Unexpected ','.
– WMomesso
carried for a reply, look there online example! works as I said!
– novic