Re: [PHP] Listing a few words from one sentence ??
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Listing a few words from one sentence ??
Say I have a sentence that contains 8 words, how do I get PHP to list just 4 of those 8 words ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Listing a few words from one sentence ??
perl regex to find the ones you want and then print them out... or you could explode then string and put each word in to one array and access the word by the array index... Example: $words = explode( , $sentence ); for( $i = 0; $i 4; $i++ ) { echo {$words[$i]}; } On Thu, 2002-11-07 at 22:29, conbud wrote: Say I have a sentence that contains 8 words, how do I get PHP to list just 4 of those 8 words ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- .: B i g D o g :. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Listing a few words from one sentence ??
Hey I guess I sort of worded my question wrong, if the sentance says Thank you for helping me with PHP I wanna be able to just have the first four words of the sentence printed so it says Thank you for helping... .: B I G D O G :. [EMAIL PROTECTED] wrote in message news:1036685027.13268.108.camel;pclnxrhunter.digitalglobe.com... perl regex to find the ones you want and then print them out... or you could explode then string and put each word in to one array and access the word by the array index... Example: $words = explode( , $sentence ); for( $i = 0; $i 4; $i++ ) { echo {$words[$i]}; } On Thu, 2002-11-07 at 22:29, conbud wrote: Say I have a sentence that contains 8 words, how do I get PHP to list just 4 of those 8 words ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- .: B i g D o g :. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php