> I'm doing a page where the front page will show "news" >
stories. What I'd > like is if the story is longer than X
> words/chars/etc, the index page will > show the first X
> words, then a link for the full story. >
> Does anyone have a good idea on how to split after a >
certain number of > words?
>
We have a "news" section with an index page that shows the
first 3 articles in our queue. These articles are limited
to their first 29 words. We then add a link to the full
article.
You can view this live: http://www.ukc.ac.uk/news/index.php
$article = fgets($fd, 8192)
/* Full text of your article. We get it from a file
using fgets($fd, 8192) */
/* remove tags if there are any */
$newscontent = strip_tags($article) ;
$pattern = " " ;
$arr = split($pattern, $newscontent, 50);
$story .= ("<p>") ;
for ($i = 0 ; $i < 29 ; $i++)
{
$story .= (" " . $arr[$i]) ;
}
$story .= (" (cont.) <a
href=\"yourarticlefilename.html\">Full article</a></p>\n");
We use this PHP in the <HEAD> of our document, so whenever
we want it to be published we just use <? echo $story ; ?>
It may not be very elegant, but it does work fine!
Hope it helps
Jose
Jose Casal-Gimenez <[EMAIL PROTECTED]>
University Web Support Officer
Communications & Development Office
G17, The Registry, University of Kent, CT2 7NZ
Tel: (01227) 823102
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]