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

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

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

本文實例講述了php實現(xiàn)修改新聞時刪除圖片的方法。分享給大家供大家參考。具體實現(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);//計算交集
foreach($oldPic as $key=>$value){
 if(!in_array($value,$intersectPic)){
 $delPic="圖片路徑".$value
  unlink($delPic);
 }
}

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

相關(guān)文章

最新評論