preg_replace

mixed preg_replace(mixed pattern, mixed replacement, mixed subject, 
[int limit]) 
pattern Regex pattern to match
replacement Replacement for the match
subject String to search using the pattern
limit Limits the number of replacements

Replaces the matches in the subject with the specified replacement.

Returns:

Subject modified by replacements

Description:

This function searches for all matches for the regular expression pattern in the supplied subject string and replaces each match with the string specified by the replacement parameter. If it’s necessary to limit the number of replacements performed, the optional limit parameter can be supplied. If limit is omitted or is -1 all matches are replaced.

The replacement string can ...

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.