"Jon Farmer" <[EMAIL PROTECTED]> wrote in message

>> From: Johannes Janson [mailto:[EMAIL PROTECTED]]
>> Sent: 13 August 2001 12:15
>> 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
> words. To do that you need to use a regexp in the SQL or explode the
> 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?

PHP Database 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