Formatting numbers
[email protected] (=?windows-1250?Q?Mitja_=8Alenc?=) Wed, 31 May 2000 13:19:09 +0200
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <316778BD9FB4D211B19C00105A3B19A43AD15B@PODROOM> |
Hi!
Is there a function for formatting numbers by inserting characters like ,
and .?
If there isn't, does someone feel like writing it? :)
I have something like the following in mind:
str_format_number($number, $character, $every [, $maxnumber])
To illustrate what it would do, here are some examples:
str_format_number(10000, ',', 3) := "100,00"
str_format_number(12345678, ',', 3) := "123,456,78"
str_format_number(12345678, ',', -3) := "12,345,678"
str_format_number(1234567890123, ',', -3, 2) := "1234567,890,123"
str_format_number(12345, '.', -2, 1) := "123.45"
str_format_number(1234567890123456, ' ', 4) := "1234 5678 9012 3456"
$number is the number to format
$character is the string to insert
$every specifies how many numbers to group together. Negative $every means
the function should start at the end.
$maxnumber is the maximum number of $character's to insert..
thanks,
Mitja