PHP/Utility Function/nl2br
Содержание
- 1 convert the newlines to
- 2 nl2br() function converts all newline (\n) characters to their HTML equivalent .
- 3 string nl2br ( string string ): changes any new line characters found in the data string into .
- 4 string nl2br ( string str ) inserts a HTML line break () before all new line characters
- 5 Wrapping Text with wordwrap() and nl2br()
convert the newlines to
<?php
$recipe = "3
1
8
3";
// convert the newlines to <br />"s.
echo nl2br($recipe);
?>
nl2br() function converts all newline (\n) characters to their HTML equivalent
.
Its syntax is: string nl2br (string string)
<?
$text_recipe = "
A
B
V";
$html_recipe = nl2br ($text_recipe);
print $html_recipe;
?>
string nl2br ( string string ): changes any new line characters found in the data string into
.
<?php
$astring = "Hello\nWorld\n\nHow are you?";
echo nl2br ($astring);
?>
string nl2br ( string str ) inserts a HTML line break (
) before all new line characters
<?
$mystr = "This is a test\nYes it is.";
$brstr = nl2br($mystr);
?>
Wrapping Text with wordwrap() and nl2br()
<?php
$string = "one line\n";
$string .= "another line\n";
$string .= "a third for luck\n";
print nl2br( $string );
?>