0
I don’t know if the title explains the doubt well, but I’ll give you an example:
A product costs 50 cents each. I want customers to select the number of products they want to take. So far, so good.
If I multiply R$0.50xNumerPar, the result is an integer.
However, if I multiply by an odd number, the result is a broken number.
My code:
if($mc_quantia == 1) {
//Se a quantia for 1, o preço será 50 centavos
$item = "R$0,50";
} else {
//Se não, pegue a quantia e divida por 2 (Porque cada 50 centavos é meio real, então eu preciso dividir por 2)
$id_4 = $mc_quantia/2;
$item = 'R$'.$id_4.',00';
}
The problem:
If the amount is 3, will return R $ 1.50,00
I’d like you to return direct the $1.50
Can you help me??
Is mixing string formatting with numbers.
– Daniel Omine