Forum Moderators: coopster

Message Too Old, No Replies

format for money

         

hal12b

8:41 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



How can I format these variables for currency?

$numberofbook = $_POST['BOOKS'];
$bookexpense = ($numberofbook * 5.95);
$shippingbook = 3.00;

I saw this online --> number_format but it didn't work.
Hal

coopster

9:56 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why didn't that work? Will money_format() [php.net] work?

hal12b

6:22 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



Ok it works, but how do you add the dollar sign? Do I need to add it manually? In ASP the Format Currency function added the $ sign.

coopster

6:30 pm on Jun 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I usually just concatenate the dollar sign if needed.
<?php 
$value = 1234.56;
print '$'.number_format($value, 2);
?>