...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

How To Format Numbers In PHP

Computing : Learning PHP

If you want to take numbers in and out of a database, from a file or anywhere else, you will often need to store them without commas.

Thus a salary figure in an INT field in a database will need just the numbers.

To format numbers can be tricky to work out though not entirely difficult.

However PHP has a helper function to insert the commas at just the right places.

The function is simple: number_format

Thus $formatted = number_format(1000000);

will give: 1,000,000. Just what we need!


Profile image!
By: Stephen

  Reply to How To Format Numbers In PHP

  Receive Our Newsletter

learn PHP picture



Questions about learn PHP:

Ask question

More Articles:
How to use your phone best at work
How to copy files quickly
How to find popular search terms