PHP with comma thousand character number processing method _php Tutorial

Source: Internet
Author: User
usually with Number_format (); To format a number, by default the thousand characters are separated by commas, such as:
Copy CodeThe code is as follows:
Echo Number_format ("10000.01231", 2);
Take 2 digits after the decimal point, the result of the output is: 10,000.1000 bits default is comma interval.

It would be a bit of a struggle if we were to verify that the numbers obtained from the client were in the background.

Lao Tong commonly used Filter_input (Input_post, "price", filter_validate_float) to verify the prices, if it is a comma with a thousand character will not be obtained.

Therefore, when you confirm that the input is a number, you must filter out all thousand characters before verifying.

In fact, few people will enter a number with a thousand character, unless it is copied or the original output value is resubmitted.

In the output we can minimize the use of a number format with thousands of characters, the output can be written like this:
Copy CodeThe code is as follows:
Format_number ("10000.01231", 2, ".", "");
So the output is 10000.01.

http://www.bkjia.com/PHPjc/324757.html www.bkjia.com true http://www.bkjia.com/PHPjc/324757.html techarticle usually use Number_format (), to format the number, by default the thousand characters are separated by commas, for example: Copy code code is as follows: Echo Number_format ("10000.01231", 2);//Take the decimal point ...

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