今天襄陽網(wǎng)站建設小編帶大家了解:thinkPHP 獲取 content中所有圖片修改路徑
$catename為傳過來的值
$pattern圖片格式
preg_match_all獲取圖片
$imgres需要遍歷的圖片
$html添加路徑
$str_replace 從新寫入返回
public function img($catename){
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png|\.bmp|\.jpeg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$catename,$match);
$imgres=$match[1];
$imgsrc=[];
$html='http://api.hbsjsd.cn';
if ($imgres!==''){
foreach ($imgres as $k=>$v){
$imgsrc[]=$html.$v;
}
}
$xstr=str_replace($imgres,$imgsrc,$catename);
return $xstr;
}
以上幾點是今天襄陽網(wǎng)站建設給大家分析下:企業(yè)網(wǎng)站建設需要哪些資料?希望對想做企業(yè)網(wǎng)站的公司有一定幫助,本公司是襄陽網(wǎng)站建設公司,襄陽網(wǎng)絡營銷公司,高端網(wǎng)站定制開發(fā)型公司