Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to take 2 decimal places in php divider

2025-03-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "php integral division how to take 2 decimal places", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "php integral division how to take 2 decimal places" bar!

In PHP, you can use the "number_format ()" function to take two decimal places to the result of division. this function is used to format numbers by grouping numbers in thousands of places. The setting parameter specifies how many decimal places are used to format numbers. The syntax is "number_format (result of integral division, 2)".

Operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

How to take 2 decimal places by php divider

The number_format () function formats numbers by grouping thousands of bits.

Note: this function supports one, two, or four parameters (not three).

Grammar

Number_format (number,decimals,decimalpoint,separator)

The parameters are expressed as follows:

Number is required. The number to format. If no other parameter is set, the number is formatted with no decimal point and a comma (,) as the thousand separator.

Decimals is optional. How many decimals are specified. If this parameter is set, the number is formatted with a period (.) 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 a thousand-bit delimiter. Only the first character of the parameter is used. For example, "xxx" only outputs "x".

Examples are as follows:

Output result:

Thank you for your reading, the above is the content of "how to take 2 decimal places in php division". After the study of this article, I believe you have a deeper understanding of how to take 2 decimal places in php division, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report