Jump to content

2 questions on limiting the amount of text displayed


ferret219

Recommended Posts

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

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";

?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.