PHP - remove <img> tag from string
Solution 1:
Try dropping the \
in front of the >
.
Edit: I just tested your regex and it works fine. This is what I used:
<?
$content = "this is something with an <img src=\"test.png\"/> in it.";
$content = preg_replace("/<img[^>]+\>/i", "(image) ", $content);
echo $content;
?>
The result is:
this is something with an (image) in it.
Solution 2:
You need to assign the result back to $content
as preg_replace
does not modify the original string.
$content = preg_replace("/<img[^>]+\>/i", "(image) ", $content);
Solution 3:
I would suggest using the strip_tags
method.