<legend id="y3o8d"></legend>
<table id="y3o8d"><dfn id="y3o8d"></dfn></table>
<b id="y3o8d"><th id="y3o8d"></th></b>
<samp id="y3o8d"><xmp id="y3o8d"><samp id="y3o8d"></samp>
<legend id="y3o8d"><b id="y3o8d"></b></legend>
鍍金池/ 問答/Java  PHP/ 關(guān)于PHP正則問題

關(guān)于PHP正則問題

以下是文章內(nèi)容

<p>文章內(nèi)容
<img src="/images/nerong.jpg">
<img src="http://www.xxx.com/images/ner...;>
<img src="/images/pic/nerong.jpg">
<img src="/file/pic/nerong.jpg">
文章測試內(nèi)容</p>

使用PHP,把沒有http的圖片地址替換成帶http域名的圖片..給沒有域名的圖片添加域名http://www.xxx.com

回答
編輯回答
熟稔
$html = '<p>文章內(nèi)容
<img src="/images/nerong.jpg">
<img src="http://www.xxx.com/images/nerong.jpg">
<img src="/images/pic/nerong.jpg">
<img src="/file/pic/nerong.jpg">
文章測試內(nèi)容</p>';
$html = str_replace('src="/','src="http://www.xxx.com/',$html);
2018年9月13日 17:15