I am saving this string into my sql db:
x
$receipt.= "$tempQty $tempItem : $tempColor :<br>
$tempService <br>
            Item Total: $$tempPrice
<br><br>";
This displays fine in a table:
3 Pants : White
Hem: $50.00
Press: $65.00
Item Total: $115.00
But when I display it in a textarea it shows up like this:
3 Pants : White <br>
Hem: $50.00
Press: $65.00 <br>
Item Total: $115.00 <br><br>
How can I get the textarea to keep the formatting but not show the <br>
tags.
Advertisement
Answer
You would want to strip out the <br>
tags and the extra space. Here’s a way to do it by splitting the array by <br>
, trimming the array parts, then joining it back together with n
.
<?php
$receipt = explode("<br>", $receipt);
foreach ($receipt as $n => $r) $receipt[$n] = trim($r);
$receipt = implode("n", $receipt);
?>
<textarea cols='60' rows='8'><?php echo $receipt;?></textarea>