php中正则替换函数ereg_replace用法实例

前端技术 2023/09/08 PHP

本文实例讲述了php中正则替换函数ereg_replace用法。分享给大家供大家参考。具体如下:

下面的实例是利用php 正则替换函数 ereg_replace来把指定的字符替换成我想需要的字符实例,代码如下:

复制代码 代码如下:
$num = \'www.phpstudy.net\';
$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==========\";

本文地址:https://www.stayed.cn/item/22138

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。