Jump to content

word wrap..


corillo181

Recommended Posts

is there any way that i can word wrap when someone puts in more than the td can handle on width..

beacuase if i gave a person a limit width to write and they write one long word together the td just expands to try and fit it all..

is there any way that i can use something to say on how many charaterc to cause a line breake..
Link to comment
Share on other sites

add that was easier than i ha din mind.. thanx..

oh but the bad thing is that it wraps every x number no matter what..ever if the word doesn't tke the spot and its the x number it wraps.. can there be any way to use it only if one word take more than it supossed to?
Link to comment
Share on other sites

You would have to to get the word lengths and check them to see if the max length was exceeded

[code]function max_word($text) {
    $words = explode(' ',$text);
    foreach($words as $w) {
        $sizes[] = strlen($w);
    }
    return max($sizes);
}

$text = 'supercallifragilistic expiallidocious is a good word to test wordwrap function';

$width = 20;

if (max_word($text) > $width)
    echo wordwrap($text,$width,'<br/>',1);
else
    echo $text;
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.