Home > Article > Backend Development > Usage example of regular replacement function ereg_replace in php_PHP tutorial
The following example is to use the regular replacement function ereg_replace in php to replace the specified characters with the character examples I want. The code is as follows:
The code is as follows:
$num = '49';
$string = "this string has four words";
$string = ereg_replace ('four', $num, $string);
echo $string;
$string ="Test text";
echo "**********$string************
";
$string = ereg_replace ("^", "
", $string);
$string = ereg_replace ("$", "
", $string);
echo "==========$string==========";