How can I show the first 30 words of a large string?
Like "This is my big text" will become "This is my big..."
I tried an algorithm but it seems there are some conflicts with tiny mce's output and nothing gets displayed at all.
[solved] Display first 30 words of a large string?
Moderator: General Moderators
[solved] Display first 30 words of a large string?
Last edited by Sindarin on Sat Aug 30, 2008 4:04 am, edited 1 time in total.
- The_Anomaly
- Forum Contributor
- Posts: 196
- Joined: Fri Aug 08, 2008 4:56 pm
- Location: Tirana, Albania
Re: Display first 30 words of a large string?
This is in the Useful Posts sticky in this forum. Seems to be exactly what you want.
Re: Display first 30 words of a large string?
Refer to the other thread you started about this, and where I already posted a solution to your problem.
Re: Display first 30 words of a large string?
I guess I can make it remove characters not words.Refer to the other thread you started about this, and where I already posted a solution to your problem.
This worked:
Code: Select all
$maxchars=300;
if (strlen (($newscontent)) > $maxchars)
{
$newscontent=substr($newscontent, 0, $maxchars);
$newscontent=$newscontent." ...<a href='edit.php?id=$newsid'><br/>More...</a>";
}