下面的實例是利用php 正則替換函數 ereg_replace來把指定的字符替換成我想需要的字符實例,代碼如下:
代碼如下: $num = 'www.jb51.net';
$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==========";