On Sat, October 29, 2005 6:36 am, Danny wrote: > I need to extract 50 words more or less from a description field. How > can i > do that?. Substr, cuts the words. Is there any other way to that, > without > using and array? I mean and implemented function in PHP 4.x > I´ve been googling around, but wordwrap, and substr is driving me > mad... Keep in mind that the "pipe" between your database and PHP is a rather small narrow expensive opening. Sucking down your ENTIRE description field to throw away all but 50 characters may not be the best use of limited resources. [This is all MOOT if you have no dreams of your site being "big" some day.] You therefore may want to consider something like: select substring(description, 1, instr(description, ' ', 50)) as description_50, substring(description, instr(description, ' ', 50), 1) as more from ... $description_50 will be 50 chars, more or less $more will tell you if there was "more" or not You will only be getting ~50 characters squeezed through that narrow expensive db <-> PHP pipeline. I believe that in MOST PHP/database applications this is going to be a better performing solution, and it's somewhat "cleaner" aesthetically than shoveling a bunch of data around that you're going to discard anyway. * instr may or may not be the right function in your database. I always forget the name of this one and have to look it up. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php