Javatpoint Logo
Javatpoint Logo

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




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA