Amy1980 Posted January 7, 2007 Share Posted January 7, 2007 Is it possible to set word max-length with wordwrap? If I wrote very long word my guestbook is crash.Thanx for helpingAmy Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/ Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Not really, [url=http://php.net/wordwrap]wordwrap[/url] work on the entire string, not each individual word within that string. Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/#findComment-154964 Share on other sites More sharing options...
Amy1980 Posted January 7, 2007 Author Share Posted January 7, 2007 Do You know any function to do that? Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/#findComment-155001 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 You'd need to roll your own. Take a look at [url=http://php.net/substr]substr[/url]. Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/#findComment-155019 Share on other sites More sharing options...
Amy1980 Posted January 7, 2007 Author Share Posted January 7, 2007 Hmm...Do you think I'll do that? I need to set max length for each word in GB's entry... Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/#findComment-155020 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Something like....[code]<?php function wordcut($string,$len) { $words = explode(" ",$string); foreach ($words as $word) { $tmp .= substr($word,0,$len)." "; } return trim($tmp); }?>[/code] Link to comment https://forums.phpfreaks.com/topic/33195-wordwrap/#findComment-155021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.