Re: Re: Show abbreviated article
| From: | Hugh Bothwell | Date: | Mon, 13 Aug 2001 14:21:18 +0000 |
| Subject: | Re: Re: Show abbreviated article | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-11289@lists.php.net to get a copy of this message | ||
"Jon Farmer" <jonfarmer@enta.net> wrote in message
news:OOEBLEHOEDLBKALJPPJCIELCCAAA.jonfarmer@enta.net...
>> From: Johannes Janson [mailto:johannes.janson@gmx.de]
>> Sent: 13 August 2001 12:15
>> To: php-db@lists.php.net
>> Subject: [PHP-DB] Re: Show abbreviated article
>> > My question is this: how can I select only those first 20 words in the
>> > PHP code?
>>
>> SELECT LEFT(YourBlobFiekd, 20) FROM YourTable;
> NO! This will return the first 20 characters from the field not the first
20
> words. To do that you need to use a regexp in the SQL or explode the
result
> in php and use the first 20 elements of the array!
... you could significantly lower bandwidth requirements by returning,
say, the first 150 characters and then explode'ing to make it 20 words.
Another thought: if you want a string of close-to-standard length,
maybe just return 100 chars and truncate to the last word boundary
using strrchr(), instead of requiring a fixed number of words?