This example describes how PHP uses the Number_format function to intercept decimals. Share to everyone for your reference, specific as follows:
You know you can use PHP's Number_format () function to group numbers by thousand. But it rounded up the numbers, so is there a way to get it to discard the decimal number immediately after the reserved bit without rounding? Please don't worry, and listen to me carefully, if you want to keep two decimal digits, you can put your number -0.005
For example:
123456.6588
The result you want is:
123,456.65
You can do this:
$num =123456.6588;
Echo Number_format ($num -0.005,2, ".", ",");
If you only want to keep integers you can
$num =123456.6588;
Number_format ($num-0.5);
The problem is done!
Add: Small knitting here recommend a site for the layout of the PHP format landscaping tools to help you in the future of PHP programming code layout:
PHP code online format Landscaping tools:
Http://tools.jb51.net/code/phpformat
In addition, because PHP belongs to the C language style, the following tool can also be used to format PHP code:
C Language Style/html/css/json code formatting landscaping Tools:
Http://tools.jb51.net/code/ccode_html_css_json
More interested in PHP related content readers can view the site topics: "PHP Math Arithmetic Skills summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP Array" operation Skills Encyclopedia, " Summary of the PHP sorting algorithm, "PHP commonly used traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and " A summary of common PHP database operations tips
I hope this article will help you with the PHP program design.