I have this value: 250,59
and this other value: 20,19
when I am both, is not calculating the cents and returns: 270
Here is my calculation:
$mo = $vl_mobra ; //VALOR 1 250,59
$mt = $vl_mat; //VALOR 2 20,19
$vt = $mo + $mt; //SOMA
See more examples:
20.000,66 //VALOR 1
10.000,99 //VALOR 2
30 // TOTAL
500,99 //VALOR 1
100,88 //VALOR 2
600 //TOTAL
function moedaPhp($str_num){
$vt = str_replace('.', '', $str_num);
$vt = str_replace(',', '.', $vt);
return $vt;
}
echo moedaPhp($vt);