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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.