note 104319 added to function.wordwrap
| From: | dynastoned at osu1 dot php dot net | Date: | Thu, 09 Jun 2011 00:08:51 +0000 |
| Subject: | note 104319 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180344@lists.php.net to get a copy of this message | ||
I wrote this because people leaving comments would spam or make words that were too long and it was
breaking the tables in my design.
So for instance if someone wanted to type "hahahhahahahhahahhahahhahahhahahahhaha" it
would go past the specified table width and break the design.
To curb this problem I needed a way to break words that were longer than 15 characters in length.
So I figured if I added a space every 15 characters that would solve my problem. This is how I did
it.
Example:
<?php
// comment the user left
$comment = "hi im here to break your page bahahahhahahhahhahhahahha. i hope this makes you mad
lolllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll.";
// breaking down each word in the $comment into arrays using explode().
$array = explode(" ", $comment);
// here i used the for loop to enable me to run each word one by one through wordwrap() and add a
space into the word if it is longer than 15 characters.
for ($i = 0, $array_num = count($array); $i < $array_num; $i++) {
$word_split = wordwrap($array[$i], 15, " ", true);
echo "$word_split ";
}
// result = hi im here to break your page bahahahhahahhah hahhahahha. i hope this makes you mad
lolllllllllllll lllllllllllllll lllllllllllllll lllllllllllllll lllllllll.
?>
----
Server IP: 69.147.83.197
Probable Submitter: 174.50.132.87
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/104319
Del: integrated -- https://master.php.net/note/delete/104319/integrated
Del: useless -- https://master.php.net/note/delete/104319/useless
Del: bad code -- https://master.php.net/note/delete/104319/bad+code
Del: spam -- https://master.php.net/note/delete/104319/spam
Del: non-english -- https://master.php.net/note/delete/104319/non-english
Del: in docs -- https://master.php.net/note/delete/104319/in+docs
Del: other reasons-- https://master.php.net/note/delete/104319
Reject -- https://master.php.net/note/reject/104319
Search -- https://master.php.net/manage/user-notes.php