Page 1 of 1

[solved] Display first 30 words of a large string?

Posted: Fri Aug 22, 2008 11:38 am
by Sindarin
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.

Re: Display first 30 words of a large string?

Posted: Fri Aug 22, 2008 11:53 am
by The_Anomaly
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?

Posted: Fri Aug 22, 2008 11:58 am
by ghurtado
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?

Posted: Fri Aug 22, 2008 12:22 pm
by Sindarin
Refer to the other thread you started about this, and where I already posted a solution to your problem.
I guess I can make it remove characters not words. :|


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>";
  }
I guess it's okay for now.