常見問題

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

常見問題

2486

字體:
今天襄陽網(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ā)型公司


[聲明]原創(chuàng)不易,請轉發(fā)者備注下文章來源(hbsjsd.cn)【速建時代】。