PHP language has an function which is used to replace a string with another string.
This Function is worked by following Syntax:
str_replace(find,replace,string,count)
Parameters:
Find – Required and used for the find value.
Replace – Required and used for the replace value.
String – Required and this is the value where string will be find and replace.
Count – Optional and this is an variable which count the number of replacement.
Examples:
<?php echo str_replace(“Hello”,”Hi”,”Hello World!”; ?>
Output:
Hi World!
In this example String ” Hello ” is replaced String ” Hi ” in String ” Hello World! “.
Tips and Warnings:
- This function is case sensitive
