search
Homephp教程php手册php实现修改新闻时删除图片的方法

这篇文章主要介绍了php实现修改新闻时删除图片的方法,涉及php正则替换的相关技巧,需要的朋友可以参考下

本文实例讲述了php实现修改新闻时删除图片的方法。分享给大家供大家参考。具体实现方法如下:

//old_contents:待修改的公告内容; //$content:修改后的公告内容 $oldPic=array(); $nowPic=array(); preg_match_all("/\php实现修改新闻时删除图片的方法/",$old_contents,$match); if(!empty($match[2])){ foreach($match[2] as $key=>$value){ array_push($oldPic,basename($value)); } } preg_match_all("/\php实现修改新闻时删除图片的方法/",$content,$testpic); if(!empty($testpic[2])){ foreach($testpic[2] as $key=>$value){ array_push($nowPic,basename($value)); } } $intersectPic=array_intersect($nowPic,$oldPic);//计算交集 foreach($oldPic as $key=>$value){ if(!in_array($value,$intersectPic)){ $delPic="图片路径".$value unlink($delPic); } }

希望本文所述对大家的php程序设计有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function