So, reading up on sprintf, and using the example I suggested from the man:
PHP Code:
$price[] = "432.1";
$price[] = "321";
$price[] = "432.10";
$price[] = ".1";
$price[] = "0.10";
// add more test scenarios above if you want
foreach( $price as $p)
echo sprintf("%01.2f", $p) . PHP_EOL ;
// gives:
432.10
321.00
432.10
0.10
0.10
EDIT
OK, sorry I posted before your reply, glad you got it sorted out quickly!
EDIT2
Creating an array of values you can test expectations against is a good trick, even better when asking questions if you prepare a set of test cases for us to test against, it doesn't apply to every question asked of course, but its a good habit to get into
Bookmarks