Re: money
| From: | Scott Houseman | Date: | Thu, 09 Jan 2003 11:13:51 +0000 |
| Subject: | Re: money | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130921@lists.php.net to get a copy of this message | ||
Hi There.
Try this
//To get a comma rather that a period:
$fTotalPrice = $iQuantity * $fUnitPrice;
$fTotalPrice = str_replace( '.', ',', $fTotalPrice );
//To check wether to add a zero to the end of a float:
// Get part of float after comma.
$iDecimal = substr( $fTotalPrice, strpos( $fTotalPrice, ',' ) +1 );
if ( strlen( $iDecimal ) == 1 )
{
$fTotalPrice .= '0';
}
I haven't tested this, but it should work.
Cheers
Scott
On 2003/01/09 12:44, Wilbert Enserink wrote:
Hi all, I'm busy making a swebstore. I have troubles with the format of money. I wanrt to display amounts like "2 products a ? 6,25 = ? 12,50" Whatever I try I can't get the comma there (it's showing a point "." and it doesn't display the second number behind the comma i.e. "12.5" Anybody knows how to make me my money? :-) regards Wilbert ------------------------- Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl info@pdd.nl --------------------------- Scott Houseman Senior Software Developer Junk Mail Publishing (Pty) Ltd T + 27 12 342 3840 ext 2806 F +27 12 342 3876 E scott@junkmail.co.za | www.junkmail.co.za A 1312 Pretorius Street, Hatfield, Pretoria P O Box 6574, Pretoria, 0001, South Africa +27 82 491 8021