note 101364 added to function.wordwrap
| From: | holdoffhunger at gmail dot com | Date: | Sun, 12 Dec 2010 17:47:48 +0000 |
| Subject: | note 101364 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174828@lists.php.net to get a copy of this message | ||
Say you have a string you want to output to the user, but you want to wordwrap the words with WBR
and ampersand-shy-semicolon tags. This will cause the word to break in half in HTML, instead of
causing the page to be huge in width. This is extremely useful for displaying full link URLs, as
many of them run on forever, and in PHP-BB, that means an entire thread will look ugly, because of
one guy posting a link. On the other hand, both the WBR and ampersand-shy-semicolon tags ignore any
spaces near them. That means, if you parsed all your PHP-BB inputted data, a sentence would like
this: "Thisisasentence." It effectively cuts out the spaces. The solution? Do an
str_replace, finding every " " (one space) and replacing it with (" ") spaces,
and then wordwrap the entire string with WBR/shy tags, every four spaces. This guarantees that
spaces within HTML will be recognized properly in all browsers, while also guaranteeing that no
words will fail to wordwrap.
----
Server IP: 69.147.83.197
Probable Submitter: 68.0.209.235
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/101364
Del: integrated -- https://master.php.net/note/delete/101364/integrated
Del: useless -- https://master.php.net/note/delete/101364/useless
Del: bad code -- https://master.php.net/note/delete/101364/bad+code
Del: spam -- https://master.php.net/note/delete/101364/spam
Del: non-english -- https://master.php.net/note/delete/101364/non-english
Del: in docs -- https://master.php.net/note/delete/101364/in+docs
Del: other reasons-- https://master.php.net/note/delete/101364
Reject -- https://master.php.net/note/reject/101364
Search -- https://master.php.net/manage/user-notes.php