$teaser = explode(" ", $article, 26));
array_pop($teaser);
$teaser = implode(" ", $teaser);

/* Chris Lambert, CTO - [EMAIL PROTECTED]
WhiteCrown Networks - More Than White Hats
Web Application Security - www.whitecrown.net
*/

----- Original Message ----- 
From: Justin French <[EMAIL PROTECTED]>
To: php <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 12:57 AM
Subject: [PHP] splitting text after 25 words


| Hi all,
| 
| I'd like to split a text block at 25 words, as a teaser for the full 
| article.  Now I know how to split at a certain character, but i don't 
| want a half word or anything, so I want (i guess) to hunt for the 25th 
| occurence of " " (a space), and split $text into two new variables,
| $text_a and $text_b.
| 
| Then I'll prolly want append something like "... click here to read 
| more" on the end of $text_a.
| 
| Seems easy enough, but I can't see anything in the manual about 
| splitting on a numbered occurence of a string (but I could be looking
| in the wrong spot :)
| 
| Running PHP4 BTW
| 
| 
| 
| Thanks heaps in advance
| Justin French
| 
| -- 
| 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]
| 
| 
| 


-- 
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]

Reply via email to