Substr () function in php, and substr function in php
// Substr ($ str, startIndex, length)
// The direction of the screenshot is from left to right.
// If the length is not specified, it is intercepted to the last one by default.
// The length is the exact number, and the negative value is the index (the maximum length)
// Note that startIndex starts from 0.
// The length includes the characters on startIndex. The length is 2, namely, startIndex and startIndex + 1.
Echo substr ('abcdef ',-4); // start is-4, which starts from the second to the last. Therefore, cdef is returned.
Echo '<br/> ';
Echo substr ('abcdef', 0); // The value 0 indicates that abcdef starts from the first one.
Echo '<br/> ';
Echo substr ('abcdef', 1, 3); // three characters starting from the second, bcd
Echo '<br/> ';
Echo substr ('abcdef',-3, 2); // two characters starting from the last three, de
Echo '<br/> ';
Echo substr ('abcdef ',-3,-2); // starts from the third to the second to the last, and does not include the second to the last, d