GroundVibes Posted January 28, 2007 Share Posted January 28, 2007 Greetings all!I have a question concerning the formatting of the text within my table.So right now I am working on a website that has user input that is displayed on the main page.So I defined my table with a width of "600px"...If the user types his text normally like this "This is a sample..."The text will automatically skip the line and it shall not exceed my 600px limit.But the problem is that if a user types "Thisisasample..."Which means the user typed a long line without any spaces, well the table exceeds the 600px limit and it just completely destroys my layout...I tried applying "word-break: break-all;" to my css document but what happens is that "This is a sample... " would display as "This is a sample..."Which broke apart the word...Is there a technique to prevent this or an actual justification of text alignment that will do soThx you advance! Link to comment https://forums.phpfreaks.com/topic/36005-text-alignment/ Share on other sites More sharing options...
AndyB Posted January 28, 2007 Share Posted January 28, 2007 I assume this is user-entered (or moron-entered) text that you save somewhere and later display ... if which case you can check the text before saving and issue an error message like "Thankyouforsubmittingyourinputwithoutanyspacesbutyouhavetotryagain" Link to comment https://forums.phpfreaks.com/topic/36005-text-alignment/#findComment-170798 Share on other sites More sharing options...
ShogunWarrior Posted January 28, 2007 Share Posted January 28, 2007 You can split up long words with a regex:[code]<?php$newstring = preg_replace( "/([^\n\r \.,]{10})/i" , '$1 ', $oldstring );?>[/code]You can change the number 10 to allow different maximum length words. Link to comment https://forums.phpfreaks.com/topic/36005-text-alignment/#findComment-170804 Share on other sites More sharing options...
GroundVibes Posted January 28, 2007 Author Share Posted January 28, 2007 Hehe, I thank you two for the fast reply on this matter.Will certainly try it out!Thank you! Link to comment https://forums.phpfreaks.com/topic/36005-text-alignment/#findComment-170809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.