PHP data is separated by a thousand-bit separator display

Source: Internet
Author: User
Use the Number_format () function in PHP to format numbers using thousands of groupings.
Number_format (Number,decimals,decimalpoint,separator)
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.
$number = 1234.56;
English notation (default)
Number_format ($number);//1,235
French notation
Number_format ($number, 2, ', ', ');//1 234,56 a space between the last single quotation mark
$number = 1234.5678;
English notation, with no thousand-points
Number_format ($number, 2, '. ', ');//1234.57
The most commonly used notation in Chinese, the thousand bits are ', ', floating-point separated as '. ', reserved two-bit floating-point number
Number_format ($number, 2, '. ', ', ');//1,234.57

The above describes the PHP data with thousands of separators separated display, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.