yami007 Posted September 1, 2009 Share Posted September 1, 2009 when a user type a long word like ( helllllllllllllllllllllllllllllllllllllllllllllllllllllo ) or longer it may affect my layout. i wanna avoid it at any cost ^^ thanks.. Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/ Share on other sites More sharing options...
Zane Posted September 1, 2009 Share Posted September 1, 2009 so you want a particular character length instead of a traditional character length Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-909969 Share on other sites More sharing options...
yami007 Posted September 1, 2009 Author Share Posted September 1, 2009 so you want a particular character length instead of a traditional character length sorry, i dont quite understand !! Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-909970 Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 You could create a regex to break up these words but i feel this be down to your HTML/CSS ! here's a concept of adding a space after the 5th repeated letter $para = "hellllllllllllllllllllo"; echo preg_replace('/(\w{5})(\1)/im', '\1 \2', $para); //returns helllll llllllllll lllllo Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-909972 Share on other sites More sharing options...
ShaunO Posted September 1, 2009 Share Posted September 1, 2009 A client side solution would be to assign the overflow-x: scroll property to the container of the text and setting a fixed width but otherwise the regex solution above ^^ should cause the words to wrap properly. Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-909994 Share on other sites More sharing options...
ReKoNiZe Posted September 1, 2009 Share Posted September 1, 2009 Or maybe he wants like: if(strlen($variable) > 12) echo 'String is too long, try again'; else echo 'Your string is short enough, you may enter'; Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-910041 Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 /*No Comment*/ Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-910051 Share on other sites More sharing options...
yami007 Posted September 1, 2009 Author Share Posted September 1, 2009 You could create a regex to break up these words but i feel this be down to your HTML/CSS ! here's a concept of adding a space after the 5th repeated letter $para = "hellllllllllllllllllllo"; echo preg_replace('/(\w{5})(\1)/im', '\1 \2', $para); //returns helllll llllllllll lllllo can i do this for a text?? in textarea Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-910229 Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 of course but i would only use it for output, $para = $_POST['elementName']; in truth i would use CSS Link to comment https://forums.phpfreaks.com/topic/172633-solved-how-can-i-avoid-long-words-on-string/#findComment-910237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.