PHP implementation of the method of deleting pictures when changing news, _php Tutorial

Source: Internet
Author: User

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:/...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.