Comma separated value file php processing method with comma thousands digits

WBOY
Release: 2016-07-29 08:47:38
Original
1507 people have browsed it

Number_format(); is usually used to format numbers. By default, thousands characters are separated by commas, for example:

Copy code The code is as follows:


echo number_format("10000.01231", 2);
/ /Take 2 decimal places, the output result is: 10,000.01 Thousands are separated by commas by default.


It would be a bit laborious if we verify the numbers in this format obtained from the client in the background.
Veteran repairmen usually use filter_input(INPUT_POST,"price",FILTER_VALIDATE_FLOAT) to verify the price. If it is a thousand-digit character with a comma, it will not be obtained.
So when confirming that the input is a number, you must first filter out all thousands characters and then verify.
In fact, few people enter numbers with thousands characters, unless they copy or resubmit the original output value.
When outputting, we can use as little number formats with thousand characters as possible. The output can be written like this:

Copy the code The code is as follows:


format_number("10000.01231",2,"." ,"");
//The output is 10000.01

The above introduces the comma-separated value file PHP method of processing comma-separated value files, including the content of comma-separated value files. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template