To replace a text with a string a function str_replace() is used. It replaces all the occurences of the string that you have searched with the string you want to give in that place.
For example:
<?php
$str = "String in which you replace the string" ;
$str = str_replace(' ', '_', $str);
echo $str
?>
The above code will display the following output:
String_in_which_you_replace_the_string
0 Comment(s)