php preg_replace 正则替换图片路径
生活随笔
收集整理的這篇文章主要介紹了
php preg_replace 正则替换图片路径
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
$str = '<img src="http://www.56ren.com/uploads/images/20100516000.jpg" height="120" width="120"><br />test1,.<img src="/uploads/images/20100516002.jpg" height="120" width="120"><br />test2, <img src="/uploads/images/20100516004.jpg" height="120" width="120"><br />test3,'; print "\n|"."****原串*****************************************************"."\n"; echo $str."\n"; print "\n"."\n"."**********替換后***********************************************"."\n"; //$parm = '/(<img.+src=\"?.+)(\"\/uploads\/)(.+\.(jpg|gif|bmp|bnp|png)\"?.+>)/i'; $parm = '/<img.+src=\"\/uploads\//'; //$replacy = array('${1}',"http://baidu.com/uc/upload",'${1}'); $replacy = 'http://baidu.com/uc/uploads/'; $re = preg_replace($parm,$replacy,$str,-1); print $re; print "\n"; echo $re[0]; print "\n";轉載于:https://my.oschina.net/osgrace/blog/920262
總結
以上是生活随笔為你收集整理的php preg_replace 正则替换图片路径的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring《二》 Bean的生命周期
- 下一篇: 如何禁止用户名,密码自动填充