Re: [PHP] comma-formatting numbers

2001-11-18 Thread Joe Stump

Here is an example of number format:



--Joe


On Sat, Nov 17, 2001 at 01:45:16PM -0800, Paul Wolstenholme wrote:
> You can do this using the number_format function or probably sprintf.
> /Paul
> 
> On Saturday, November 17, 2001, at 01:36  PM, Scott Dudley wrote:
> 
> >
> >i'm new to php and am having difficulty translating this tiny awk
> >function that i use to comma format numbers.  can someone assist?  my
> >stumbling block thus far have been the fact the the php regex matching
> >functions don't return the byte offset within the haystack and the regex
> >replace functions don't support the awk and perl-like ampersand "&" in
> >the replacement pattern.  please help and thanks.
> >
> >function commas(num) {
> >  while (num ~ /[0-9][0-9][0-9][0-9]/)
> >sub (/[0-9][0-9][0-9]$|[0-9][0-9][0-9][,]/, ",&", num)
> >
> >  return num
> >}
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

Joe Stump <[EMAIL PROTECTED]>

"How would this sentence be different if pi equaled 3?" 




msg40412/pgp0.pgp
Description: PGP signature


Re: [PHP] comma-formatting numbers

2001-11-17 Thread Paul Wolstenholme

You can do this using the number_format function or probably sprintf.
/Paul

On Saturday, November 17, 2001, at 01:36  PM, Scott Dudley wrote:

>
> i'm new to php and am having difficulty translating this tiny awk
> function that i use to comma format numbers.  can someone assist?  my
> stumbling block thus far have been the fact the the php regex matching
> functions don't return the byte offset within the haystack and the regex
> replace functions don't support the awk and perl-like ampersand "&" in
> the replacement pattern.  please help and thanks.
>
> function commas(num) {
>   while (num ~ /[0-9][0-9][0-9][0-9]/)
> sub (/[0-9][0-9][0-9]$|[0-9][0-9][0-9][,]/, ",&", num)
>
>   return num
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] comma-formatting numbers

2001-11-17 Thread Scott Dudley


i'm new to php and am having difficulty translating this tiny awk
function that i use to comma format numbers.  can someone assist?  my
stumbling block thus far have been the fact the the php regex matching
functions don't return the byte offset within the haystack and the regex
replace functions don't support the awk and perl-like ampersand "&" in
the replacement pattern.  please help and thanks.

function commas(num) {
  while (num ~ /[0-9][0-9][0-9][0-9]/)
sub (/[0-9][0-9][0-9]$|[0-9][0-9][0-9][,]/, ",&", num)

  return num
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]