Home » PHP number_format() function

PHP number_format() function

by Online Tutorials Library

PHP string number_format() function

PHP string ‘number_format()’ is in-built PHP function. It is used to format a number with grouped thousands. It supports one, two or three parameters (not three).

Syntax:

Parameter Description Required/Optional
number The number being formatted. Required
decimal Set the number of decimal point. Optional
decimalpoint Sets the separator for the decimal point. Optional
separator Set the thousand separator Optional

Example 1

Output:

Your number is:199.9  By using 'number_format()' function :200  

Example 2

Output:

Your number is:199.9  By using 'number_format()' function :199.90  

Example 3

Output:

Your number is:1000000  By using 'number_format()' function :1,000,000  

Example 4

Output:

Your number is:1000000  By using 'number_format()' function :1,000,000.00  

Next TopicPHP String

You may also like