Sunday 15 April 2012

number formatting - PHP using number_format and displaying the decimal point correctly -



number formatting - PHP using number_format and displaying the decimal point correctly -

my number 495 plain , simple.

i'm trying format number have display $4.95

what i've done number_format($number, 2, '.', '')

but outputs 495.00

i know can't difficult. familiar number_format?

i need add together decimal 2 numbers right cents displayed. ex. 4.95, 12.58, 23.39... idea.

thank you.

if you're working integers instead of floats, you'd first have split 100.

$number = 495; echo number_format($number/100, 2, '.', '')

php number-formatting

No comments:

Post a Comment