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
https://forums.phpfreaks.com/topic/10722-word-wrap/
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
https://forums.phpfreaks.com/topic/10722-word-wrap/#findComment-40061
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.