substr

Extracts a substring and returns it:

$ret = substr( $expr, $offset[, $len]);

If offset is negative, substr starts that far from the end of the string. If len is omitted, the rest of the string is returned.

Here is an example comparing substr() with Python slicing, 12.1.3.