By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,514 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,514 IT Pros & Developers. It's quick & easy.

Latest News - Shortening to 100 characters

P: 73
Hello, I'm pretty sure I've seen this here before but I've tried searching (not sure on the keywords to search) and nothing came up so here's what I want to do

I've just developed a news system and I want to display it on the front page, but shorten it to say 100 characters or 200 characters, then I'll add a link to the full story using GET.

So basically, I just need to know how to shorten the result from the database to so many words / characters.

Thanks,
Jeigh.
Jul 31 '07 #1
Share this Question
Share on Google+
2 Replies


kovik
Expert 100+
P: 1,044
You could easily do so using substr(), but then you may run into problems with accidentally cutting off HTML, breaking words widway through them, etc. Those are things that you'd need to program against if they bother you.
Jul 31 '07 #2

P: 73
Cheers, exactly what I needed and it works perfectly.

Shouldn't have to worry to much about cutting off words as I'll just display it like:

The quick brown fox ju...

and the result from the database is text only.

Thanks,
Jeigh.
Jul 31 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.