sotusotusotu Posted July 29, 2007 Share Posted July 29, 2007 Hey, I have developed a simple from system that allows users to input some comments. This all works fine, however when I try to retrieve the comments I only want to display 100 characters. I am new to PHP, but was wondering if there is a string function that will let me take the data from a table in my database and then only display 100 characters followed by "..." afterwards. Also I have thought of a potential problem... if someone enters less than 100 characters I only want to show the amount they have entered. can anyone help? Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Take a look at substr. In particular the user contributed examples should have something that'll do what you need. Quote Link to comment Share on other sites More sharing options...
calabiyau Posted July 29, 2007 Share Posted July 29, 2007 also, you should do some kind of checking loop that checks if the last character is a blank space or not and continues to chop off the last letter until it encounters a blank space, cuz it looks ugly to have these 100 character summaries cut off in the middle of a word, like this for examp.... Quote Link to comment Share on other sites More sharing options...
sotusotusotu Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks guys! I will look up substr. Any ideas how I would go about doing a check loop to see if the word cuts out half way through though? Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Did you look at the user contributed examples? Like I said... there should be something there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.