Jump to content

Display the details


Vinsanity

Recommended Posts

If I understand you correctly, you want a few words of the paragraph and then a [Read More] type link.

I may be off base here, but I have done this by pulling the paragraph out of the db and then using an explode function to break each sentence into an array and then display the first sentence.

There may be an easier way to do it, but this works pretty good. You can explode on a period to get sentences, or on ' ' whitespace to break it down into each word, then simply echo the number of words you want from the array.
Link to comment
https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-171682
Share on other sites

here is some basic code using the substr like jesirose said. BASIC code. look at it. dont copy paste it. write it out yourself. think about it. :) sorry jesirose i am giving the OP some code!

[code=php:0]
$full_news = "Hello! This is some news (it dosnt have to be news) that will be cut down then a link to read me would be displayed. This is so cool.";
if(strlen($full_news) > 25){ //25 is the amount of characters to show.
$short_news = substr($full_news, 0, 25)."... <a href='link/to/full/news.php'>[read more]</a>";
}

echo $short_news;
[/code]

just a small example.
Link to comment
https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-172416
Share on other sites

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.