-2

I want to know how can I add comma's to numbers. I want to change number 5,272,945.31 to 52,72,945.31 Is it possible with a php function?

I have try this code:

number_format($amount,2);
srishti
  • 1
  • 3
  • 1
    see [Numbering Format in PHP](https://stackoverflow.com/questions/10042485/how-to-display-currency-in-indian-numbering-format-in-php) – Regolith Jul 26 '17 at 07:34
  • 1
    Possible duplicate of [How to display Currency in Indian Numbering Format in PHP](https://stackoverflow.com/questions/10042485/how-to-display-currency-in-indian-numbering-format-in-php) – user3942918 Jul 26 '17 at 07:46

1 Answers1

0

The value assigned to $amount isn't formatted correctly, however, number_format doesn't like , so strip these out before passing to number_format.

number_format(str_replace(',', '', $amount), 2);

Example: https://3v4l.org/dPAEp

steadweb
  • 15,364
  • 3
  • 33
  • 47