Php tutorial substr () function parameter description and example tutorial
/*
String substr (string $ string, int $ start [, int $ length]), which can be used to search for matched strings or characters in a long string. $ String is the string to be processed, $ start is the start position, and $ length is the length to be selected.
$ Length: reads characters from left to right for positive data,
When $ length is negative, it reads characters from the right to the left.
*/
$ Rest1 = substr ("abcdef", 2); // returns "cdef"
$ Rest2 = substr ("abcdef",-2); // returns "ef"
$ Rest1 = substr ("abcdef", 0, 0); // returns ""
$ Rest2 = substr ("abcdef", 0, 2); // returns "AB"
$ Rest3 = substr ("abcdef", 0,-1); // returns "abcde"
$ Rest4 = substr ("abcdef", 2, 0); // returns ""
$ Rest5 = substr ("abcdef", 2, 2); // returns "cd"
$ Rest6 = substr ("abcdef", 2,-1); // returns "cde"
$ Rest7 = substr ("abcdef",-2, 0); // returns ""
$ Rest8 = substr ("abcdef",-2, 2); // returns "ef"
$ Rest9 = substr ("abcdef",-2,-1); // returns "e"
/*
String is required. Specifies that a part of the string is to be returned.
Start is required. Specifies where the string starts.
Charlist is optional. Specifies the length of the string to be returned. The default value is until the end of the string.
Positive number-start at the specified position of the string
Negative number-starting from the specified position at the end of the string
0-Start at the first character in the string
*/