Re: wordwrap not working
| From: | Joel Boonstra | Date: | Thu, 21 Feb 2002 03:35:40 +0000 |
| Subject: | Re: wordwrap not working | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85667@lists.php.net to get a copy of this message | ||
<snip>
> it should print like this:
>
> The quick brown fox
> jumped over the lazy dog.
>
> but it still printing like this:
>
> The quick brown fox jumped over the lazy dog.
HTML treats bunches of whitespace as one space. Look at the source of the
page; you'll see that it's doing what it should.
If you want your HTML to appear wordwrapped, modify your PHP to use the
'nl2br()' function:
<?
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = nl2br(wordwrap( $text, 20 ));
echo "$newtext\n";
?>
This will convert all newlines to <br> tags, and your HTML output will
look just like your text output.
Joel
--
[ joel boonstra | jboonstra@gospelcom.net ]