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); } }