to remove all html tags from a html
$ht = "<p>lorem ipsum</p><p>323</p>";
$str = strip_tags($ht);
echo $str;
problem - displaying the result in a textarea I'm getting - lorem ipsum323
what I need is:
lorem ipsum
323
is there a way to set a new line after each closing tag - </p>
, </div>
and </span>
You can just use str_replace
:
$ht = "<p>lorem ipsum</p><p>323</p>";
$ht = str_replace(['</p>', '</div>', '</span>'], "\n", $ht);
$str = strip_tags($ht);
echo $str;
Output:
lorem ipsum
323
Sample here: https://3v4l.org/a2t4D