PHP/Utility Function/nl2br — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:37, 26 мая 2010
Содержание
- 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
<source lang="html4strict">
<?php
$recipe = "3 1 8 3"; // convert the newlines to
"s. echo nl2br($recipe);
?>
</source>
nl2br() function converts all newline (\n) characters to their HTML equivalent
.
<source lang="html4strict">
Its syntax is: string nl2br (string string) <?
$text_recipe = " A B V"; $html_recipe = nl2br ($text_recipe); print $html_recipe;
?>
</source>
string nl2br ( string string ): changes any new line characters found in the data string into
.
<source lang="html4strict">
<?php $astring = "Hello\nWorld\n\nHow are you?"; echo nl2br ($astring); ?>
</source>
string nl2br ( string str ) inserts a HTML line break (
) before all new line characters
<source lang="html4strict">
<?
$mystr = "This is a test\nYes it is."; $brstr = nl2br($mystr);
?>
</source>
Wrapping Text with wordwrap() and nl2br()
<source lang="html4strict">
<?php
$string = "one line\n"; $string .= "another line\n"; $string .= "a third for luck\n"; print nl2br( $string );
?>
</source>