The way PHP retrieves the number of a string is to pass the string as a parameter to the substr function, and set the starting point and the length of the string to be returned, for example [substr("Hello world", 6)].
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
php has a very rich function library, including a function substr(), which can take out any part of the string. Returns FALSE on failure, or an empty string.
Syntax:
substr(string,start,length)
Parameters:
string Required. Specifies a part of the string to be returned.
#start Required. Specifies where in the string to begin.
#length Optional. Specifies the length of the string to be returned. The default is until the end of the string.
Code example:
Running result:
world
Related video sharing:php video tutorial
The above is the detailed content of How to get the number of string in php. For more information, please follow other related articles on the PHP Chinese website!