ferret219 Posted February 8, 2008 Share Posted February 8, 2008 Hello there, I have a couple of questions and would appreciate any help. 1) I have a basic news system running but on the list news items page, I would like to display a shortened version of the main body of the news item. i.e. if the text is over 150 characters then display a "(...More)" link at the end to the full item. 2) When displaying the body text of the news items, I am using tables but if the body has a really long line of text, it extends the table. I would like to force a new line when the text reaches the edge of the table. Thanks in advance, Chris Quote Link to comment https://forums.phpfreaks.com/topic/90095-2-questions-on-limiting-the-amount-of-text-displayed/ Share on other sites More sharing options...
Caesar Posted February 8, 2008 Share Posted February 8, 2008 1. substr() 2. Why not define the width of your table in your CSS, and avoid running your string/text through more PHP functions? Quote Link to comment https://forums.phpfreaks.com/topic/90095-2-questions-on-limiting-the-amount-of-text-displayed/#findComment-461927 Share on other sites More sharing options...
ferret219 Posted February 8, 2008 Author Share Posted February 8, 2008 Thanks for the quick reply. Just another quick one, when the are more than 10 items on the page, how do I then display the next 10 on another page. Thanks again, Chris Quote Link to comment https://forums.phpfreaks.com/topic/90095-2-questions-on-limiting-the-amount-of-text-displayed/#findComment-461969 Share on other sites More sharing options...
rcorlew Posted February 8, 2008 Share Posted February 8, 2008 You could limit the string to a set number of characters like this: <?php $string = "My text from whatever source": $str= substr($string, 10); //The number limits your str to that many characters including spaces echo "$str"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/90095-2-questions-on-limiting-the-amount-of-text-displayed/#findComment-461972 Share on other sites More sharing options...
GingerRobot Posted February 8, 2008 Share Posted February 8, 2008 Thanks for the quick reply. Just another quick one, when the are more than 10 items on the page, how do I then display the next 10 on another page. Thanks again, Chris It's called pagination. Google for it and you'll find plenty of tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/90095-2-questions-on-limiting-the-amount-of-text-displayed/#findComment-461987 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.