Formatting numbers

From: Date: Wed, 31 May 2000 11:19:09 +0000
Subject: Formatting numbers
Groups: php.version4 
Request: Send a blank email to php-version4+get-15969@lists.php.net to get a copy of this message
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

« previous php.version4 (#15969) next »