FXMAR 发表于 2017-4-10 10:44:10

Replace current src and add the host name using Regx in PHP

<?php
$content = '
<img alt="" src="/a.jpg/" />   
<img alt="" src="b.jpg" />
<img alt="" src="test.php" />
<img alt="" title=" " src="d.jpg" />
';
$content = preg_replace('#src="(/|)#is', 'src="http://wuchengyi.iteye.com', $content);
echo $content;
?>
页: [1]
查看完整版本: Replace current src and add the host name using Regx in PHP