lorem ipsum

323

"; $str = strip_tags($ht); echo $str; problem - displaying the result in a text" /> lorem ipsum

323

"; $str = strip_tags($ht); echo $str; problem - displaying the result in a text" /> lorem ipsum

323

"; $str = strip_tags($ht); echo $str; problem - displaying the result in a text"/>

set a new line after each closing tag

105 Views Asked by At

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>

1

There are 1 best solutions below

0
Chris Haas On BEST ANSWER

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