Msg#: 4250901 posted 2:43 am on Jan 10, 2011 (gmt 0)
Nope, tried "F" and still did it. While reading my O'Reilly PHP book last night (I'm a beginner), they said printf is a rarely used function and they more or less said to use number_format() which I never even heard of.
I printed side by side: $_SESSION['test'] = 1501; $j = round(($_SESSION['test']*.01),2); printf("%01.2f",$j); print "<br>".number_format($j,2);
and got: 15.015 15.01
So I guess at this point I'm just going to stop wondering why, and move on with number_format. Live and learn.
Msg#: 4250901 posted 9:34 am on Jan 10, 2011 (gmt 0)
Hhhmm, that seems odd. printf() might be a lesser used function, but its sister function sprintf() [uk2.php.net] - which uses the exact same syntax and AFAIK behaves the same as printf(), but returns a string rather than outputting it directly - certainly is!
printf() / sprintf() certainly come into their own when formatting a string of multiple values or of more complexity. number_format() [uk2.php.net] is also not locale aware in itself.
I'm curious, what version of PHP / OS have you tried this on? Have you tried another server?