新聞動態(tài)

位置:首頁 新聞動態(tài) 常見問題

高端網(wǎng)站定制開發(fā):thinkPHP 獲取 content中所有圖片修改路徑

新聞動態(tài)
2020年04月21日 閱讀:2705次
今天襄陽網(wǎng)站建設(shè)小編帶大家了解: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;
}
以上幾點(diǎn)是今天襄陽網(wǎng)站建設(shè)給大家分析下:企業(yè)網(wǎng)站建設(shè)需要哪些資料?希望對想做企業(yè)網(wǎng)站的公司有一定幫助,本公司是襄陽網(wǎng)站建設(shè)公司,襄陽網(wǎng)絡(luò)營銷公司,高端網(wǎng)站定制開發(fā)型公司

上一篇

下一篇