欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php實(shí)現(xiàn)修改新聞時(shí)刪除圖片的方法

 更新時(shí)間:2015年05月12日 11:37:01   作者:vivi  
這篇文章主要介紹了php實(shí)現(xiàn)修改新聞時(shí)刪除圖片的方法,涉及php正則替換的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了php實(shí)現(xiàn)修改新聞時(shí)刪除圖片的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

//old_contents:待修改的公告內(nèi)容;
//$content:修改后的公告內(nèi)容
$oldPic=array();
$nowPic=array();
preg_match_all("/\<IMG(.*?)src=\"(.*?)\">/",$old_contents,$match);
if(!empty($match[2])){
 foreach($match[2] as $key=>$value){
 array_push($oldPic,basename($value));
 }
}
preg_match_all("/\<IMG(.*?)src=\"(.*?)\">/",$content,$testpic);
if(!empty($testpic[2])){
 foreach($testpic[2] as $key=>$value){
 array_push($nowPic,basename($value));
 }
}
$intersectPic=array_intersect($nowPic,$oldPic);//計(jì)算交集
foreach($oldPic as $key=>$value){
 if(!in_array($value,$intersectPic)){
 $delPic="圖片路徑".$value
  unlink($delPic);
 }
}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論