
Read Time:45 Second
The str_replace is a builtin PHP function used to find and replace specific strings
Not just limited to simple text but can be used with arrays as well
str_replace function takes four parameters Search, Replace, String of Text, Count
While the count is Optional
Str_replace Usage
Here we will replace the String Basudev with the string Mahesh If you wish you can pass the $count param if you want to know how many times the text is replaced then passing this parameter is useful, but for now, we are not used it
Str_replace Usage with arrays
let’s see how we can use this str_replace function with arrays,
here we will be removing all vowels from the given text
Str_replace function is helpful when handling dangerous strings, we can prevent dangerous web attacks such as XSS