xxxxxxxxxx
<?php
echo str_replace(“red”, “blue”, “red carpet”);
?>
xxxxxxxxxx
<?php
//str_replace("Original Value", "Value to be replaced", "String");
$result = str_replace("1", "2", "This is number 1");
// Output: This is number 2
?>
xxxxxxxxxx
<?php
$string = "Hello PHP";
$replace = str_replace("PHP", "JS", $string);
echo $replace; // Hello JS
?>
xxxxxxxxxx
# for replace someting in string use this function
# str_replace("1st param for select","2nd param for replace with","3rd your string")
<?php
$string = str_replace(" ", "_", "Hello World");
// Output will be : Hello_world
?>
xxxxxxxxxx
<?php
$string = str_ireplace("FoX", "CAT", "the quick brown fox jumps over the lazy dog");
echo $string; // the quick brown CAT jumps over the lazy dog
?>