Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Number Formatting - Quick question !!
August 24, 2007, 7:40 am
rate this thread
My database holds numbers like:
I need these to be displayed as
I'll add the '£' sign, so the end result is
How do I do that. ? The vaule are coming from $number
Also some of the numbers may be negatives:
Is there any easy way to detect negitives ?
Ideally I'd like to be able to show positive number in one color and
negitive in red on screen.
Re: Number Formatting - Quick question !!
Here is an example using sprintf, straight from www.php.net
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$formatted = sprintf("%01.2f", $money);
// echo $formatted will output "123.10"
- » Quick and Simple CMS solution/script; does it exist?
- — Previous thread in » PHP Scripting Forum