Forum Moderators: coopster

Message Too Old, No Replies

Shorten a long string to .

         

natural number

3:16 am on Nov 9, 2006 (gmt 0)

10+ Year Member



I'm outputting a large amount of data from mysql and I want to shorten it.

I want to change this display "Once upon a midnight dreary, while I pondered weak and weary. "

to something like this "Once upon a midnight ..."

Any ideas guys? I bet I'll get a fix in 10 minutes.

coopster

3:22 am on Nov 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You have a couple of options, you can truncate the data in your SQL statement or you can substring it after it comes out using PHP.

Here are some examples with options ...

How to avoid words being chopped with SUBSTR [webmasterworld.com]
Which string() to use to display first 500 words of data [webmasterworld.com]
syntax for selecting first 100 characters from a mysql field [webmasterworld.com]

natural number

3:23 am on Nov 9, 2006 (gmt 0)

10+ Year Member



wow coopster, that was fast! thanks.