Glossary Term
preg_replace()
preg_replace() — Perform a regular expression search and replace.
preg_replace() — Searches subject for matches to pattern and replaces them with replacement.
To match an exact string, rather than a pattern, consider using str_replace or str_ireplace instead of this function.
Inputs: pattern: The pattern to search for. It can be either a string or an array with strings. Several PCRE modifiers are also available. replacement: The string or an array with strings to replace. If this parameter is a string and the pattern parameter is an array, all patterns will be replaced by that string. If both pattern and replacement parameters are arrays, each pattern will be replaced by the replacement counterpart. subject: The string or an array with strings to search and replace. If subject is an array, then the search and replace is performed on every entry of subject, and the return value is an array as well. limit: The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
Returns: preg_replace returns an array if the subject parameter is an array, or a string otherwise. If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or null if an error occurred.
Term Connections
Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.
Loading term connections…
