substr

string substr(string string, int start, [int length]) 
string String to operate on
start Offset of the substring
length Length of the substring

Gets part of a string.

Returns:

String; FALSE on error

Description:

substr() is used to get part of a string. The part of the string to be returned is specified as a range using the start and length arguments.

Behavior of the start and length arguments is interesting, allowing for a great deal of flexibility in choosing what part of the string to replace. See the following table for details.

Argument Value Behavior
start Non-negative integer Start the substring at start characters into the string.
start Negative integer Start the substring at start characters from the end of the string. ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.