"Nl2br()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 7개는 보이지 않습니다)
1번째 줄: 1번째 줄:
;nl2br()
;nl2br()
==JavaScript==
[[category: JavaScript]]
<syntaxhighlight lang='JavaScript'>
function nl2br(str){ 
    return str.replace(/\n/g, "<br />"); 
console.log( nl2br("Hello\nWorld") );
// Hello<br />World
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
function nl2br(str){ 
    return str.replace(/\n/g, "<br />\n"); 
console.log( nl2br("Hello\nWorld") );
// Hello<br />
// World
</syntaxhighlight>
==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='php'>
<syntaxhighlight lang='php'>
echo nl2br("Hello\nWorld");
$result = nl2br("Hello\nWorld");
 
echo $result;
# Hello<br />
# Hello<br />
# World
# World
</source>
echo strlen( $result );
# 17
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[HTML br 태그]]
*[[HTML br 태그]]
*[[뉴라인]]
*[[br2nl()]]

2020년 11월 2일 (월) 02:34 기준 최신판

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 }}