In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces php how to remove decimal places, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Php to remove decimal places method: 1, use intval () function to get the integer part of the variable, syntax "intval ($number)"; 2, use floor () function to round down, syntax "floor ($number)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of removing decimal places in php
Method 1: use the intval () function
The intval () function is used to get the integer value of a variable. Syntax format:
Int intval (mixed $var [, int $base = 10])
$var: the numerical value to be converted to integer.
$base: the base used for conversion.
If base is 0, determine which binary to use by examining the format of the var:
Use hexadecimal (hex) if the string includes the prefix of "0x" (or "0X"); otherwise
Use octal (octal) if the string starts with "0"; otherwise
Decimal (decimal) will be used.
The intval () function is often used for data type conversion, converting variables of string and floating point types to integer types.
Example: convert a decimal to an integer (remove decimal places)
Output result:
Method 2: use the floor () function to round down
The floor () function rounds down to the nearest integer. Syntax format:
Floor ($number)
$number: required. Specifies the value that needs to be rounded down.
Example: rounding decimal places (removing decimal places)
Output result:
Add: two other methods of decimal rounding
Use the ceil () function-- rounding up, adding 1 to the integer part if there is a decimal.
Output result:
Use the round () function-- rounded
Output result:
Thank you for reading this article carefully. I hope the article "how to remove decimal places in php" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.