• Post category:PHP

What is  str_replace function in PHP


Learn what is str_replace function in php is with example code. If we need to perform substitution within a string. PHP also has the str_replace() function, designed specifically to perform find-and-replace operations. This function accepts three arguments, the search term, the replacement term, and the string in which to perform the replacement. We can also replace white space. See the below Example code:


str_replace(search, replace, stringname)


$str = "johh@gmail.com";
echo str_replace('@', ' at ', '$str); // replace '@' with 'at'

john at gmail.com

Leave a Reply