note 102560 added to function.nl2br

From: Date: Mon, 21 Feb 2011 20:58:42 +0000
Subject: note 102560 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-177192@lists.php.net to get a copy of this message
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

« previous php.notes (#177192) next »