You can use nl2br to add the line break element BR in the sequence of line break characters:
$html = nl2br($plain);
Note that the BR elements are just added:
nl2br("foo\nbar") === "foo\n<br />bar"
To prevent strip_tags from removing P and BR tags, specify them in the second parameter:
$clean = strip_tags($html, '<p><br>');
Gumbo source share