[PHP] decimal places

2002-11-26 Thread Bryan Koschmann - GKT
Hello,

Does anyone here have a good way to make sure dollar amounts are formatted
properly? I have something that returns data, but the problem is it's
stored where any trailing zero isn't kept, like this:

$16.95 or $172.82 are fine

$17.90 or $190.20 come back as $17.9 and $190.2

I would like to make sure they are all properly formatted. Any ideas?

Thanks in advance,

Bryan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] decimal places

2002-11-26 Thread Kevin Stone
Try.. printf(%.2f, $amount);
-Kevin

- Original Message -
From: Bryan Koschmann - GKT [EMAIL PROTECTED]
To: PHP General [EMAIL PROTECTED]
Sent: Tuesday, November 26, 2002 12:29 PM
Subject: [PHP] decimal places


 Hello,

 Does anyone here have a good way to make sure dollar amounts are formatted
 properly? I have something that returns data, but the problem is it's
 stored where any trailing zero isn't kept, like this:

 $16.95 or $172.82 are fine

 $17.90 or $190.20 come back as $17.9 and $190.2

 I would like to make sure they are all properly formatted. Any ideas?

 Thanks in advance,

 Bryan


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] decimal places

2002-11-26 Thread Van Andel, Robert

$amount = 17.9;
$dollars = $ . number_format($amount, 2);
echo $dollars;

you should see $17.90.
Robbert van Andel 


-Original Message-
From: Bryan Koschmann - GKT [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 11:29 AM
To: PHP General
Subject: [PHP] decimal places


Hello,

Does anyone here have a good way to make sure dollar amounts are formatted
properly? I have something that returns data, but the problem is it's
stored where any trailing zero isn't kept, like this:

$16.95 or $172.82 are fine

$17.90 or $190.20 come back as $17.9 and $190.2

I would like to make sure they are all properly formatted. Any ideas?

Thanks in advance,

Bryan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





This email and any files transmitted with it are confidential and intended solely for 
the use of the individual or entity to whom they are addressed. If you have received 
this email in error please notify the system manager. This message contains 
confidential information and is intended only for the individual named. If you are not 
the named addressee you should not disseminate, distribute or copy this e-mail.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] decimal places

2002-11-26 Thread Matt Vos
As an addition to that, if you don't want the thousands separator to be ',';
do the following:

$amount = 1234.567
$fmt1 = number_format($amount,2);
$fmt2 = number_format($amount,2,'.','');
echo($fmt1\n$fmt2);

This will output:
1,234.56
1234.56

Matt
- Original Message -
From: Van Andel, Robert [EMAIL PROTECTED]
To: Bryan Koschmann - GKT [EMAIL PROTECTED]; PHP General
[EMAIL PROTECTED]
Sent: Tuesday, November 26, 2002 2:36 PM
Subject: RE: [PHP] decimal places



$amount = 17.9;
$dollars = $ . number_format($amount, 2);
echo $dollars;

you should see $17.90.
Robbert van Andel


-Original Message-
From: Bryan Koschmann - GKT [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 11:29 AM
To: PHP General
Subject: [PHP] decimal places


Hello,

Does anyone here have a good way to make sure dollar amounts are formatted
properly? I have something that returns data, but the problem is it's
stored where any trailing zero isn't kept, like this:

$16.95 or $172.82 are fine

$17.90 or $190.20 come back as $17.9 and $190.2

I would like to make sure they are all properly formatted. Any ideas?

Thanks in advance,

Bryan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] decimal places

2002-11-26 Thread Bryan Koschmann - GKT
Perfect!

Thanks for the quick responses everyone! I really appreciate the help.

Have a good day!

Bryan

On Tue, 26 Nov 2002, Matt Vos wrote:

|As an addition to that, if you don't want the thousands separator to be ',';
|do the following:
|
|$amount = 1234.567
|$fmt1 = number_format($amount,2);
|$fmt2 = number_format($amount,2,'.','');
|echo($fmt1\n$fmt2);
|
|This will output:
|1,234.56
|1234.56
|
|Matt
|- Original Message -
|From: Van Andel, Robert [EMAIL PROTECTED]
|To: Bryan Koschmann - GKT [EMAIL PROTECTED]; PHP General
|[EMAIL PROTECTED]
|Sent: Tuesday, November 26, 2002 2:36 PM
|Subject: RE: [PHP] decimal places
|
|
|
|$amount = 17.9;
|$dollars = $ . number_format($amount, 2);
|echo $dollars;
|
|you should see $17.90.
|Robbert van Andel
|
|
|-Original Message-
|From: Bryan Koschmann - GKT [mailto:[EMAIL PROTECTED]]
|Sent: Tuesday, November 26, 2002 11:29 AM
|To: PHP General
|Subject: [PHP] decimal places
|
|
|Hello,
|
|Does anyone here have a good way to make sure dollar amounts are formatted
|properly? I have something that returns data, but the problem is it's
|stored where any trailing zero isn't kept, like this:
|
|$16.95 or $172.82 are fine
|
|$17.90 or $190.20 come back as $17.9 and $190.2
|
|I would like to make sure they are all properly formatted. Any ideas?
|
|Thanks in advance,
|
|Bryan
|
|
|--
|PHP General Mailing List (http://www.php.net/)
|To unsubscribe, visit: http://www.php.net/unsub.php
|
|
|
|
|
|This email and any files transmitted with it are confidential and intended
|solely for the use of the individual or entity to whom they are addressed.
|If you have received this email in error please notify the system manager.
|This message contains confidential information and is intended only for the
|individual named. If you are not the named addressee you should not
|disseminate, distribute or copy this e-mail.
|
|--
|PHP General Mailing List (http://www.php.net/)
|To unsubscribe, visit: http://www.php.net/unsub.php
|
|
|
|



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Decimal Places

2002-10-30 Thread dwalker
?php function
DoFormatNumber($theObject,$NumDigitsAfterDecimal,$UseParensForNegativeNumber
s,$GroupDigits)
{

$currencyFormat=number_format($theObject,$NumDigitsAfterDecimal,$UseParensFo
rNegativeNumbers,$GroupDigits);
 return ($currencyFormat);
}
?


?php echo DoFormatNumber( $Product-Fields(UnitPrice), 2, -2, -2) ?
-Original Message-
From: Andrew Wilson [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Tuesday, October 29, 2002 11:34 PM
Subject: [PHP] Decimal Places


Hay guys,
I have two variables ( integers ) that are being minused one from the other
and i am printing the result to the screen but i am getting unwanted
decimals.

print ($eall - $sall) / 1000;

My question is what is the easiest way to strip decimals off the above
result. The only way i know around it is if i piped the above statement
into
another varible and set that variable to an integer then printed that.

I dont really want to do this as i will end up with 50 extra variables.
Thanks in advance for your comments.

Andrew Wilson
Technical Support
Netway Networks
8920-8877


Netway Networks Pty Ltd
(T) 8920 8877
(F) 8920 8866



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Decimal Places

2002-10-29 Thread Andrew Wilson
Hay guys, 
I have two variables ( integers ) that are being minused one from the other
and i am printing the result to the screen but i am getting unwanted
decimals.
 
print ($eall - $sall) / 1000;

My question is what is the easiest way to strip decimals off the above
result. The only way i know around it is if i piped the above statement into
another varible and set that variable to an integer then printed that. 

I dont really want to do this as i will end up with 50 extra variables.
Thanks in advance for your comments. 

Andrew Wilson 
Technical Support 
Netway Networks 
8920-8877 


Netway Networks Pty Ltd 
(T) 8920 8877 
(F) 8920 8866 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Decimal Places

2002-10-29 Thread Martin Towell
have a look at number_format()

-Original Message-
From: Andrew Wilson [mailto:will;netwaynetworks.com.au]
Sent: Wednesday, October 30, 2002 3:34 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Decimal Places


Hay guys, 
I have two variables ( integers ) that are being minused one from the other
and i am printing the result to the screen but i am getting unwanted
decimals.
 
print ($eall - $sall) / 1000;

My question is what is the easiest way to strip decimals off the above
result. The only way i know around it is if i piped the above statement into
another varible and set that variable to an integer then printed that. 

I dont really want to do this as i will end up with 50 extra variables.
Thanks in advance for your comments. 

Andrew Wilson 
Technical Support 
Netway Networks 
8920-8877 


Netway Networks Pty Ltd 
(T) 8920 8877 
(F) 8920 8866 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php