有关php正则替换函数ereg_replace的用法,在php编程中ereg_replace用来根据正则表达式中的匹配值,去替换相应的字符,可以看看本文举的这个例子。
利用php正则表达式替换函数 ereg_replace替换字符为其它字符。
例子:
复制代码 代码示例:
$num = 'www.jb200.com';
$string = "this string has four words. <br>";
$string = ereg_replace ('four', $num, $string);
echo $string;
$num = '49';
$string = "this string has four words";
$string = ereg_replace ('four', $num, $string);
echo $string;
$string ="测试用文字";
echo "**********$string**********<p>";
$string = ereg_replace ("^", "<br>", $string);
$string = ereg_replace ("$", "<br>", $string);
echo "==========$string==========";