Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php replace paragraph to newline

how to replace <p>hello</p> <p>world</p> to hello<br />world <br />

I've tried searching on stack but there is no matched result.

like image 500
ytdm Avatar asked Sep 05 '25 17:09

ytdm


1 Answers

You could do this by using str_replace() function.

For instance:

$string = "<p>hello</p> <p>world</p>";
$string = str_replace('<p>', '', $string);
$string = str_replace('</p>', '<br />' , $string);
like image 67
Rubain Avatar answered Sep 07 '25 06:09

Rubain