Im parsing xml using php and one of my variables receive a long decimal value.
$ctr = 0.00529440333938;
But I need to make this number as 0.52%, so I tried multiplying by 100 and forcing just 2 decimals.
$real_ctr = $ctr * 100;
echo number_format($real_ctr, 2) . "%";
I get as result 0.00% instead 0f 0.52%
And then I tried adding 1 just for testing purpose
$real_ctr = $ctr + 1;
and I get as result 0.005294403339381. It adds 1 at the end.
Any suggestions how can I get around this issue?
It seams
$ctrwhat you get from the XML parser is a string. Use:to make sure your variable is a float.