How to get the digit of a number by php
This article is about how php gets the digits of a number. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Get method: 1, using the substr () function, the syntax is "substr ($num, nMel 1,1)", the parameter n is the number of digits that need to be obtained; 2, using the mb_substr () function, the syntax is "mb_substr ($num, nmur1,1)", and the parameter n is the number of digits that need to be obtained.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php gets the digit of a number
Method 1: use the substr () function
Description: the substr () function can intercept a certain length of characters from a specified position in a string.
Method 2: use the mb_substr () function
Description: the mb_substr () function is similar to the substr () function, which can also intercept a certain length of characters from the specified position of the string; but unlike the substr () function, the mb_substr () function is valid not only for English characters, but also for Chinese characters.
Thank you for reading! This is the end of the article on "how to get the number of digits of php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!