Reputation: 4527
I have a page where i display all post coming from the database, I don't want to display all the contents just the excerpts from it. This is just easy i know, i could search the internet for it, but i don't know what you call it. Anybody can point me to the right road thanks. BTW i'm using codeigniter for my site.
example of what i am talking about is:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**The Title**
sdfgsjdhfglksjhfdgksdjfhglskdjfghlsdkjfhglskdjfhgslkjdfhg(read more).
**The second title**
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum(read more).
Upvotes: 1
Views: 1229
Reputation: 1150
or you can use the built-in text helper http://s.zah.me/KJXK6o and use one of the two functions word_limiter
or character_limiter
like
$string = "Here is a nice text string consisting of eleven words.";
$string = word_limiter($string, 4);
// Returns: Here is a nice…
Upvotes: 3
Reputation: 30170
There are a bunch of ways you can do this depending on where you want to cut it off.
An easy way is to split the string with a space then take the first X spaces/
$excerpt = array_slice( explode( " ", $text ), 0, 30 );
This way it wont cut the text off in the middle of a word.
Upvotes: 2