The str_replace function is used to locate and replace the specific string values in a given string.
php script Syntax :
The str_replace function contain three arguments. The first argument defines the text to be replaced.
Second argument defines the replacement text.
Third argument defines the text that is analyzed.
php 7 Sample Code : sample php program
php program Code Explanation :
In this example we used string replace function for the first parameter as text to be replaced, so “forum” will be replaced by the second parameter “tutorial points” and the third parameter is the content that is from where these needs to take place, here we have “welcome to wikitechy technical forum”.
php coding Sample Output :
In the output statement “'welcome to wikitechy technical forum!....” the term “forum” has been replaced as “tutorial points”, so now we got the output as “welcome to wikitechy technical tutorial points!....”.