Originally posted by loureiro
thanks! i was looking at printf! i thought there would be a function though to keep the format of a number in proper currency format however i was wrong! thanks again though!
no you're not wrong watch this
function currency_format($rawNumber) {
$formatted = sprintf("%01.2f", $rawNumber);
return $formatted;
} //end currency
and for my next trick a generic version
function number_format($rawNumber,$pre,$post) {
$numFormat = "%0" . $pre . "." . $post . "f";
$formatted = sprintf($numFormat, $rawNumber);
return $formatted;
} //end currency
Now you pick one of these functions stick it into an include file called 'common.php' then in every script you write include common.php and you'll have access to this function. My common.php file is about 200 lines long currently.