The PHP Number_format () function uses thousands of groupings to format the implementation code of a number _php tutorial

Source: Internet
Author: User
Definition and usage
The Number_format () function formats numbers by using thousands of groupings.

Grammar
Number_format (Number,decimals,decimalpoint,separator)

Parameter description
Number required. The number to format. If no other parameters are set, the number is formatted with no decimal point and comma (,) as the delimiter.

Decimals is optional. How many decimal places are specified. If this parameter is set, the number is formatted with a dot (.) as the decimal point.

Decimalpoint is optional. Specifies a string to use as a decimal point.

Separator is optional. Specifies the string to use as the thousand separator. Only the first character of the parameter is used. For example, "XYZ" only outputs "X".
Note: If this parameter is set, all other parameters are required.

Hints and Notes
Note: The function supports one, two, or four parameters (not three).

Example:
Copy the Code code as follows:
Echo Number_format ("1000000");
Echo Number_format ("1000000", 2);
Echo Number_format ("1000000", 2, ",", ".");
?>

Output:
Copy the Code code as follows:
1,000,000
1,000,000.00
1.000.000,00

http://www.bkjia.com/PHPjc/328074.html www.bkjia.com true http://www.bkjia.com/PHPjc/328074.html techarticle define and use the Number_format () function to format numbers by using thousands of groupings. The syntax Number_format (number,decimals,decimalpoint,separator) parameter describes number required. To format ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.