Re: Extract of a Paragraph
| From: | Adam Bregenzer | Date: | Wed, 04 Feb 2004 20:36:11 +0000 |
| Subject: | Re: Extract of a Paragraph | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176841@lists.php.net to get a copy of this message | ||
On Wed, 2004-02-04 at 09:00, Daniel Perez Clavero wrote:
> To Extract the first 50 words, should I use str_word_count, and
> explode/implode or there´s another way, much simple.
>
> Any sample would be apreciated.
> Regards
Regular expressions should do the trick:
$extract = array();
preg_match('/^(\W*\w+){50}/', $paragraph, $extract);
$extract = array_shift($extract);
--
Adam Bregenzer
adam@bregenzer.net
http://adam.bregenzer.net/