How does php judge how many decimal places there are?
This article mainly introduces "how to judge the decimal places in php". In the daily operation, I believe that many people have doubts about how to judge the decimal places in php. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to judge the decimal places in php". Next, please follow the editor to study!
There are several decimal places in php judgment: 1, using "strlen (substr ($num, strrpos ($num,'.) + 1)") sentence; 2, using "strlen (array_pop (explode ('.', $num))" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php's method of judging how many decimal places a number has
Method 1: with the help of strrpos (), substr (), strlen () functions
Output result:
five
Method 2: with the help of explod (), array_pop (), strlen () functions
Output result:
three
At this point, the study of "how to judge how many decimal places there are in php" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!