i have a varible like so:
$Text= "Hello
My
Code"
so what i want to happen is where ever there is a new line to insert
so it should look like
$NewText = "Hello<br>
My<br>
Code"
*
You can use nl2br
, preg_replace
or str_replace
:
$text = "Hello\nMy\nCode";
$newText = nl2br($text);
$newText = preg_replace('/\r?\n/', "<br>\n", $text);
$newText = str_replace("\n", "<br>\n", $text);