wordwrapping

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

wordwrapping

Post by HiddenS3crets »

Wordwrap doesn't work if there is a very long string with no spaces in it. Thus, the wordwrap function becomes ineffective. How can I fix this so it will break a long string anyways?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

According to the manual this produces:

Code: Select all

<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", 1);

echo "$newtext\n";
?>
this:

Code: Select all

A very
long
wooooooo
ooooord.
Teh boolean cut parameter must be set to 1.
Post Reply