[PHP] changed number_format function

2004-08-27 Thread Ma SivaKumar
A copy of php manual I downloaded a year back 
has the following about the behaviour of 
number_format function

?php
$number = 1234.56;
// english notation (default)
$english_format_number = 
number_format($number);
// 1,234.56
?

The latest on-line version is changed as 
below
?php
$number = 1234.56;
// english notation (default)
$english_format_number = 
number_format($number);
// 1,234

In many un-updated sites I could see the old 
version. I am not successful finding the 
change log related to this. 

Does any one know why it is changed thus?

What is the best way to format numbers to put 
only the thousand separator without removing 
or adding decimal places to the number.

For example,

1000 should return 1,000
1000.5 should return 1,000.5
1000.25 should return 1,000.25 
so on.

I am looking at sprintf now. 

Thanks and Best regards,


Ma SivaKumar

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



Re: [PHP] changed number_format function

2004-08-27 Thread Ramil Sagum
On Fri, 27 Aug 2004 14:06:56 +0530, Ma SivaKumar [EMAIL PROTECTED] wrote:
 
 The latest on-line version is changed as
 below
 ?php
 $number = 1234.56;
 // english notation (default)
 $english_format_number =
 number_format($number);
 // 1,234
 
 What is the best way to format numbers to put
 only the thousand separator without removing
 or adding decimal places to the number.
 
 For example,
 
 1000 should return 1,000
 1000.5 should return 1,000.5
 1000.25 should return 1,000.25
 so on.
 
 
 Ma SivaKumar

Thus says http://www.php.net/number_format

string number_format ( float number [, int decimals])
string number_format ( float number, int decimals, string dec_point,
string thousands_sep)
.
.
.
If two parameters are given, number will be formatted with decimals
decimals with a dot (.) in front, and a comma (,) between every
group of thousands.




ramil

http://ramil.sagum.net

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



Re: [PHP] changed number_format function

2004-08-27 Thread Justin Patrin
On Fri, 27 Aug 2004 14:06:56 +0530, Ma SivaKumar [EMAIL PROTECTED] wrote:
 A copy of php manual I downloaded a year back
 has the following about the behaviour of
 number_format function
 
 ?php
 $number = 1234.56;
 // english notation (default)
 $english_format_number =
 number_format($number);
 // 1,234.56
 ?
 
 The latest on-line version is changed as
 below
 ?php
 $number = 1234.56;
 // english notation (default)
 $english_format_number =
 number_format($number);

number_format($number, 2);

 // 1,234
 
 In many un-updated sites I could see the old
 version. I am not successful finding the
 change log related to this.
 
 Does any one know why it is changed thus?
 
 What is the best way to format numbers to put
 only the thousand separator without removing
 or adding decimal places to the number.
 
 For example,
 
 1000 should return 1,000
 1000.5 should return 1,000.5
 1000.25 should return 1,000.25
 so on.
 
 I am looking at sprintf now.
 
 Thanks and Best regards,
 
 Ma SivaKumar
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] changed number_format function

2004-08-27 Thread Marek Kilimajer
Justin Patrin wrote:
number_format($number, 2);
Does not work. Desired results:
1000 should return 1,000
1000.5 should return 1,000.5
1000.25 should return 1,000.25
so on.
Actual results:
1000= 1,000.00
1000.5  = 1,000.50
1000.25 = 1,000.25
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] changed number_format function

2004-08-27 Thread Justin Patrin
On Fri, 27 Aug 2004 18:48:16 +0200, Marek Kilimajer [EMAIL PROTECTED] wrote:
 Justin Patrin wrote:
  number_format($number, 2);
 
 
 Does not work. Desired results:
 
 
 1000 should return 1,000
 1000.5 should return 1,000.5
 1000.25 should return 1,000.25
 so on.
 
 Actual results:
 
 1000= 1,000.00
 1000.5  = 1,000.50
 1000.25 = 1,000.25
 

OIC. Yep, I don't think you can do that with number_format.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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