Use PHP DOM to parse and add in it. Like this:
$html = '';
//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('textarea');
//get text and add
then remove last
$lines = $nodes->item(0)->nodeValue;
//split it by newlines
$lines = explode("\n", $lines);
//add
at end of each line
foreach($lines as $line)
$output .= $line . "
";
//remove last
$output = rtrim($output, "
");
//display it
var_dump($output);
This outputs:
string ' put returns between paragraphs
for linebreak add 2 spaces at end
indent code by 4 spaces
quote by placing > at start of line
' (length=141)