Php implements the method of deleting images when modifying news ,. Php implements the method of deleting an image when modifying news. this example describes how php deletes an image when modifying news. Share it with you for your reference. The specific implementation method is as follows: php implements the method of deleting an image when modifying news,
This example describes how to delete an image when modifying news in php. Share it with you for your reference. The specific implementation method is as follows:
// Old_contents: the announcement to be modified; // $ content: the modified announcement content $ oldPic = array (); $ nowPic = array (); preg_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); // calculate the intersection foreach ($ oldPic as $ key => $ value) {if (! In_array ($ value, $ intersectPic) {$ delPic = "Image path". $ value unlink ($ delPic );}}
I hope this article will help you with php programming.
Example: This article describes how to delete an image when modifying news in php. Share it with you for your reference. The specific implementation method is as follows :/...