Link to home
Start Free TrialLog in
Avatar of tr5
tr5

asked on

% character in sprintf

Hi
This is crazy, but I can't get a % character to appear in a sprintf() statement.
What is wrong with this:
$str = sprintf("Percentage: %0.2f%", 53.0);
echo "str = $str<br>";
prints only "str = "
The % after the 0.2f causes the problem. I tried escaping it but it doesn't work. In c you can use a % in a printf. What's the deal here?

Thanks
tr5
ASKER CERTIFIED SOLUTION
Avatar of callrs
callrs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of callrs
callrs

e.g.
$str = sprintf("Percentage: %0.2f%%", 53.0);