Can I ask the normal expression of PHP to get all the pictures in the specified folder, and then delete the related pictures of the operation

Source: Internet
Author: User
Tags php regular expression
Ask PHP regular expression to get all the picture names in the specified folder, and then delete the related pictures of the operation
Recently helped a friend to do a backstage, which is used FCKeditor as an editor, but FCKeditor did not provide upload pictures after the picture name written to the database function, delete the news only delete the data, the news in the picture is still in the server, so that in the future will accumulate a lot of junk pictures. So you want to delete the picture when you read the news content in the Upimages folder in the relevant pictures, and then delete.

For example, I have 4 pictures in the news link


Ask the master of the regular expression how to write, and get the name of the image to delete after the code. THANK YOU!!!!




------Solution--------------------
Just like this ...

PHP Code
$news _content = "   , if (Preg_match_all ("//", $news _content, $getvalues)) {        foreach ($getvalues [1] as $filename) {            unlink (' upimages/'. $filename);        }   }
  • 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.