note 42105 deleted from function.nl2br by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 03 May 2004 18:44:43 +0000 |
| Subject: | note 42105 deleted from function.nl2br by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69167@lists.php.net to get a copy of this message | ||
Note Submitter: gnyffox at hotmail
----
If you want pretty printing do this:
<?php
function pretty_nl2br($text, $cnt_tabs) {
for ($i = 0; $i < $cnt_tabs; $i++) {
$pr_tabs .= "\t";
}
$text = ereg_replace("\n", "<br/>\n".$pr_tabs, $text);
$text = ereg_replace("\r", "", $text);
$text = $pr_tabs.$text;
return $text;
}
?>
First arg is the text that we'll work with, second is the number of tabs before each line.