According to the post here, the code below can remove the HTML tag, such as <div>
. But I found that the end tag </div>
still remain in the string.
$content = "<div id=\"header\">this is something with an <img src=\"test.png\"/> in it.</div>";
$content = preg_replace("/<div[^>]+\>/i", "", $content);
echo $content;
I have tried something below, but still not work, how can I fix this issue?
$content = preg_replace("/<\/div[^>]+\>/i", "", $content);
$content = preg_replace("/<(/)div[^>]+\>/i", "", $content);
Thanks