Home > Article > Backend Development > Substr() function parameter description and usage examples in php, substr parameter description_PHP tutorial
The example in this article describes the parameter description and usage of the substr() function in php. Share it with everyone for your reference. The details are as follows:
string substr(string $string, int $start [, int $length]), it can be used to find matching strings or characters in a longer string, $string is the string to be processed, $start is the position to start selecting, $length is the length to be selected.
$length reads characters from left to right for positive data.
When $length is a negative number, characters are read from right to left.
string is required and specifies a part of the string to be returned.
start is required and specifies where to start the string.
charlist is optional and specifies the length of the string to be returned. The default is until the end of the string.
Positive number - starts at the specified position in the string
Negative number - starts at the specified position from the end of the string
0 - Start
at the first character in the stringPHP example code is as follows:
I hope this article will be helpful to everyone’s PHP programming design.