The string function substr () in php (). Syntax of the string function substr () in php: stringsubstr (string $ stringint $ start [, int $ end]). This function is also intercepted in bytes (not characters, when intercepting Chinese characters, note that the string function substr () in php ()
Syntax: string substr (string $ string int $ start [, int $ end]). This function is also truncated by byte (not a character). Note the following when intercepting Chinese characters, in addition, the starting position of the truncation must be on the left of the ending position, that is, it is always intercepted from left to right.
$ Str = "Hello world! ";
Echo substr ($ str, 3 ),"
"; // Result lo world!
Echo substr ($ str, 3, 8 ),"
"; // Result lo wo
Echo substr ($ str,-6 ),"
"; // At this time, the second parameter is a negative number, indicating that it is truncated from the sixth position to the next position, and the result is world.
Echo substr ($ str,-6,-3 ),"
"; // When the third parameter is negative, it indicates the truncation length and the result is wor.
Substring () syntax: string substr (string $ string int $ start [, int $ end]). This function is also truncated by byte (not a character, when intercepting Chinese characters, pay attention to the following ,...