Hello George,
Try something like this:
$var = '25.5';
$var = sprintf("%.2f", $var);
echo $var;
GP> Hi,
GP> I want to be able to display the results of some calculations as currency
GP> such as £25.50, but round($var,2) produces £25.5.
GP> I've tried writing my own function but that just fouled
George,
have a look at number_format()
(http://us2.php.net/manual/en/function.number-format.php). that in
combo with round() should do the trick.
On Fri, 3 Dec 2004 16:16:27 -, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> You could try concatenating a string of "0"s (£25.5000) on the en
http://us2.php.net/manual/en/function.number-format.php
use number_format function.
string number_format ( float number [, int decimals] ) string number_format (
float number, int decimals, string dec_point, string thousands_sep )
> -Original Message-
> From: George Pitcher [mailto:[EMA
You could try concatenating a string of "0"s (£25.5000) on the end and using
substr on the whole to get your £25.50.
$currency = $currency . "000";
$currency = substr( $currency, 0, strpos($currency,'.') + 3 )
Neil Morgan
-Original Message-
From: George Pitcher [mailto:[EMAIL PROTECTED]
Hi,
I want to be able to display the results of some calculations as currency
such as £25.50, but round($var,2) produces £25.5.
I've tried writing my own function but that just fouled up the calculation.
Any tips or suggestions?
Cheers
George in Oxford
--
PHP Windows Mailing List (http://www
php-windows Digest 3 Dec 2004 15:50:30 - Issue 2494
Topics (messages 25109 through 25112):
Re: Category/SubCategory
25109 by: Bobo Wieland
Re: How to configure PHP5 with support of Java 1.4 on window platform
25110 by: Seung Hwan Kang
Re: new mysql.dll for php...
25