473,382 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Latest News - Shortening to 100 characters

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
2 1167
kovik
1,044 Expert 1GB
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
Jeigh
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

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

Similar topics

2
by: kaptain kernel | last post by:
how does one shorten an array based on a key value. Say I have this: array("Car1"=>"Porsche","Car2"=>"Merc","Car3"=>"Ford","Car4"=>"Toyota"); and I want to pop "Car2" out of the array,...
3
by: asdfkajsdflkjsadlfkjoewqifoeiwjf | last post by:
Hi I have a string: $string="aslkjdaslkdiwedweodij" When printing it out, I want it to be limited to 10 characters followed by "..." Result:
4
by: Dariusz | last post by:
I have a guestbook on one of my sites where the entires are formatted to be x pixles in width. Now the text is input and output from a "blob" field from a database... but when people input long...
16
by: Robbie | last post by:
Hi All This is a belter that my little brain can't handle. Basically I have 1 SQL table that contains the following fields: Stock Code Stock Desc Reference Transaction Date
0
by: kellyonlyone | last post by:
E-XD++ MFC Library Enterprise Edition V9.80 is released (100% Source Code)! ("The only Flow/Diagramming Kits that provides full source code of components for MFC and ActiveX in a single package!")...
42
by: Noah Roberts | last post by:
The latest MS compiler "depricates" certain functions including stricmp. The function stricmp is not part of the C++ standard, it is part of POSIX. The question I have, is it really necissary for...
1
by: metaperl | last post by:
There is no end to the number of frantic pleas for help with characters in the realm beyond ASCII. However, in searching thru them, I do not see a workable approach to changing them into other...
0
by: Edwina Rothschild | last post by:
Verily I say unto thee, that Roy Schestowitz spake thusly: http://weblog.infoworld.com/openresource/archives/2007/05/why_open_source.ht ml I caught your comment and link to the InformationWeek...
2
by: skanemupp | last post by:
windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.