Reputation: 15
I am trying to format $c (basically it is blocks of information that I need to appear in paragraph form). I am using nl2br() to introduce line breaks. So I have the following code:
$search_output .= "*<i>$a</i>- <br/><b>field c: </b> $c <i>$b</i><br />";
echo nl2br($c);
The problem is $c shows up twice. Once as unformatted in $search_output and then formatted in echo nl2br(), but it pops up at the very top of the page and messes up my layout.
I want to merge nl2br($c) into $search_output.
I tried this:
$search_output .= "*<i>$a</i>- <br/><b>field c: </b> nl2br($c) <i>$b</i><br />";
It doesn't work.
Please help. I am new at this. And losing my mind. nl2br() works separately, but I need the formatted content as part of $search_output.
Upvotes: 0
Views: 809
Reputation: 3113
use the right syntax. Its an function/method and not an variable
$search_output .= "*<i>$a</i>- <br/><b>field c: </b> " . nl2br($c) . " <i>$b</i><br />";
Upvotes: 0
Reputation: 798536
Stop the string, put the code, start the string again. And don't forget to concatenate.
$search_output .= "*<i>$a</i>- <br/><b>field c: </b> " . nl2br($c) . " <i>$b</i><br />";
Upvotes: 1