PHP implements the method of deleting a picture when the news is modified.
This article explains how PHP removes pictures when it modifies news. Share to everyone for your reference. The implementation method is as follows:
Old_contents: The content of the announcement to be modified;//$content: Revised post content $oldpic=array (); $nowPic =array ();p reg_match_all ("/\/", $old _contents, $match), if (!empty ($match [2])) {foreach ($match [2] as $key = = $value) {Array_push ($oldPic, basename ($value));}} Preg_match_all ("/\/", $content, $testpic), if (!empty ($testpic [2])) {foreach ($testpic [2] as $key = + $value) {Array_ Push ($nowPic, basename ($value)); }} $intersectPic =array_intersect ($nowPic, $oldPic);//Compute intersection foreach ($oldPic as $key + = $value) {if (!in_array ($value, $ Intersectpic) {$delPic = "picture path". $value unlink ($delPic);}}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/998552.html www.bkjia.com true http://www.bkjia.com/PHPjc/998552.html techarticle PHP Implementation to modify the news when the method of deleting pictures, this article describes the PHP implementation of the changes in the news when the method of deleting pictures. Share to everyone for your reference. The specific implementation method is as follows:/...