php&mysql

[php] 줄바꿈 태그 nl2br()

pm1122Dev 2021. 2. 4. 11:43
728x90
반응형

nl2br ( string $string , bool $use_xhtml = true ) : string

 

줄바꿈 기호 \n를 <br>태그로 변경해준다.

 

<?php
echo nl2br("Welcome\r\nThis is my HTML document", false);

//결과값
Welcome<br>
This is my HTML document
?>

<?php
$string = "This\r\nis\n\ra\nstring\r";
echo nl2br($string);

//결과값
This<br />
is<br />
a<br />
string<br />
?>
728x90
반응형