How does php determine if there is a decimal point?
This article mainly introduces php how to judge whether there is a decimal point related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe everyone after reading this php how to judge whether there is a decimal point article will have a harvest, let's take a look.
Php's method of judging whether there is a decimal point: 1. Use "strpos (numeric string,'.')" Syntax, if you return the position where the decimal point first appears in the string, there is a decimal point; 2. Use "strrpos (numeric string,'.')" Statement, if it returns the position where the decimal point last appeared in the string.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php's method of judging whether there is a decimal point or not
Method 1: use the strpos () function
Use the strpos () function to get the position of the decimal point in the string for the first time, syntax:
Strpos (numeric string,'.')
There is if the location is returned, but not if FALSE is returned.
Example:
Method 2: use the strrpos () function
Use the strrpos () function to get the position of the last occurrence of the decimal point in the string, syntax:
Strrpos (numeric string,'.')
There is if the location is returned, but not if FALSE is returned.
This is the end of the article on "how to judge whether there is a decimal point in php". Thank you for reading! I believe you all have a certain understanding of the knowledge of "php how to judge whether there is a decimal point or not". If you want to learn more, you are welcome to follow the industry information channel.