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
$var1 = 'hello.world';
$var2 = str_replace(".", "-", $var1);
echo $var2; // hello-world
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
$var1 = 'hello_john';
$var2 = str_replace("_", "-", $var1);
echo $var2; // hello-john