note 102560 added to function.nl2br
[email protected] Mon, 21 Feb 2011 12:58:42 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
I dunno if its faster than the regex sample but it rebuilds the string, so it doesnt have \r in it. (it returns one long string without line breaks\tabs or whatever).
function nl2tag($str, $tag){
$string = "<{$tag}>";
for ($i = 0; $i < strlen($str); $i++) {
if (ord($str[$i]) > 31) {
$last = $str[$i];
$string .= $str[$i];
} elseif ($str[$i] == "\n" && $last != "\n") {
$last = $str[$i];
$string .= "</{$tag}><{$tag}>";
}
}
$string .= "</{$tag}>";
return $string;
}
----
Server IP: 83.137.20.135
Probable Submitter: 84.26.188.20
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- https://master.php.net/note/edit/102560
Del: integrated -- https://master.php.net/note/delete/102560/integrated
Del: useless -- https://master.php.net/note/delete/102560/useless
Del: bad code -- https://master.php.net/note/delete/102560/bad+code
Del: spam -- https://master.php.net/note/delete/102560/spam
Del: non-english -- https://master.php.net/note/delete/102560/non-english
Del: in docs -- https://master.php.net/note/delete/102560/in+docs
Del: other reasons-- https://master.php.net/note/delete/102560
Reject -- https://master.php.net/note/reject/102560
Search -- https://master.php.net/manage/user-notes.php