Home > Backend Development > PHP Problem > How to delete img tag in php

How to delete img tag in php

藏色散人
Release: 2023-03-04 12:04:01
Original
2738 people have browsed it

How to delete the img tag in php: first create a PHP sample file; then use "preg_replace("/How to delete img tag in php] \>/i", "(image) ", $content);" Just delete the img tag. [^>

How to delete img tag in php

Recommendation: "PHP Video Tutorial"

Code example:

<?
    $content = "this is something with an <img src=\"test.png\"/> in it.";
    $content = preg_replace("/<img[^>]+\>/i", "(image) ", $content); 
    echo $content;
?>
Copy after login

The result is:

this is something with an (image)  in it.
Copy after login

The above is the detailed content of How to delete img tag in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template