substr_replace

string substr_replace(string string, string replacement, 
int start, [int length]) 
string String to search
replacement Replacement string
start Starting offset of the substring
length Length of the substring

Replaces part of a string with another string.

Returns:

String

Description:

substr_replace() is used to replace part of a string with another. The substring to be replaced is specified as a range using the start and length arguments. The string to replace this range of characters is specified with the replacement argument.

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

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.