Nl2br()

nl2br()

1 JavaScript[ | ]

function nl2br(str){  
    return str.replace(/\n/g, "<br />");  
}  

console.log( nl2br("Hello\nWorld") );
// Hello<br />World
function nl2br(str){  
    return str.replace(/\n/g, "<br />\n");  
}  

console.log( nl2br("Hello\nWorld") );
// Hello<br />
// World

2 PHP[ | ]

$result = nl2br("Hello\nWorld");

echo $result;
# Hello<br />
# World
echo strlen( $result );
# 17

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}