Re: Listing a few words from one sentence ??
| From: | Ernest E Vogelsinger | Date: | Fri, 08 Nov 2002 08:01:28 +0000 |
| Subject: | Re: Listing a few words from one sentence ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123328@lists.php.net to get a copy of this message | ||
At 23:29 07.11.2002, conbud said:
--------------------[snip]--------------------
>Say I have a sentence that contains 8 words, how do I get PHP to list just 4
>of those 8 words ?
--------------------[snip]--------------------
Let's assume your words are delimited by one or more blanks, so you could:
$arwords = split(' ',$sentence); // make an array
$arwords = array_slice($arwords, 0, 4); // return the first 4 entries
echo join(' ', $arwords); // and show them
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/