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;
?>

 

你可能感兴趣的:(Replace current src and add the host name using Regx in PHP)