# 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?>
$phrase="You should eat fruits, vegetables, and fiber every day.";$healthy=array("fruits","vegetables","fiber");$yummy=array("pizza","beer","ice cream");$newphrase=str_replace($healthy,$yummy,$phrase);// => $newphrase = You should eat pizza, beer, and ice cream every day
phpCopy<?php$mystring="This is my string.";echo("This is the string before replacement: ");echo($mystring);echo("
");$mynewstring=str_replace(" my "," ",$mystring);echo("Now, this is the string after replacement: ");echo($mynewstring);?>
phpCopy<?php$mystring="This is my string.";echo("This is the string before replacement: ");echo($mystring);echo("
");$mynewstring=str_replace(" my "," ",$mystring,$count);echo("Now, this is the string after replacement: ");echo($mynewstring);echo("
");echo("The number of replacements is: ");echo($count);?>