简体   繁体   中英

why isn't nl2br() working

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.

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 />";

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 />";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM