Trying to convert this \"0.274509817\"
to a nice precentage like 27%
The string is a dynamic value from an API.
What's the problem with intval($a * 100) . '%'
?
$number = 0.274509817;
echo round( $number * 100 ), '%';
round((float)$value * 100) . '%'
and after that, append
"%"
to get the percent sign (e.g. if used with sprintf).
$percent = round((float)$str * 100 ) . '%';
Where $str
= "0.274509817"