Searching and Replacing
Searching and replacing allows modifying text based on patterns.
Functions include:
str_replace()preg_replace()
Example
Section titled “Example”$text = "I like cats";
echo str_replace("cats", "dogs", $text);Using regex replace
Section titled “Using regex replace”$text = "Version 123";
echo preg_replace("/[0-9]+/", "X", $text);