PHP MySQL Tutorial
Learn PHP and MySQL

PHP Number Formats

100% of people found this useful
PHP Number Formats

PHP's solution to formatting number is the number_format() function. This function take 4 arguments but only the first is mandatory.

The arguments are :

1. The number itself
2. Decimals
3. Decimal points
4. Thousand separators

Here are some examples :

1. number_format(123456) yields 123,456
2. number_format(123456, 2) yields 123,456.00
3. number_format(123456, 3) yields 123,456.000
4. number_format(123.456, 2) yields 123.46
5. number_format(123.456, 3) yields 123.456
6. number_format(123456, 2, ',', '.') yields 123.456,00
7. number_format(123456, 2, '.', ',') yields 123,456.00
8. number_format(123456.7, 2, '.', ',') yields 123,456.70


Note : this function CANNOT accept three arguments. Only one, two, or four. That means something like number_format(123456, 2, ',') is not a valid function call

Recent Comments

By: jenefee Posted on 07-11-2015 12:10 AM

Thanks such a lot with this fantastic new internet site. I’m terribly unemployed up to point out it to anyone. It makes American state therefore glad your Brobdingnagian understanding and knowledge have a brand new channel for attempting into the globe. http://judibola.co/

By: john9 Posted on 09-13-2015 1:46 AM
By: umangbhat3 Posted on 10-12-2015 9:15 AM

I agree with what you are saying.

Great post.

BTW check this out,

Happy Halloween 2015

Happy Halloween 2015 Wishes

Happy Halloween Wishes

Happy Halloween quotes

Happy Halloween images

www.happyrakshabandhan2015wishes.com

Powered by Community Server (Non-Commercial Edition), by Telligent Systems