TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Text Limiter (http://www.talkphp.com/advanced-php-programming/1550-text-limiter.html)

WinSrev 11-29-2007 11:58 PM

Text Limiter
 
Hey,

Looking for a way to somehow, show 3 lines of text, every certain amount of characters it breaks and starts a new line once it's at the end of the third line it shows a ... if theres more text but it can't break in the middle of a word but if the word is too long move it to the next line with the rest, any ideas on how to do this?

Thanks!

Haris 11-30-2007 12:07 AM

http://php.net/wordwrap should help.

Wildhoney 11-30-2007 02:33 AM

Yep, the wordwrap function along with the concatenation for the ellipsis would do it, no?

WinSrev 11-30-2007 03:45 PM

Pretty useful function, i used my current text limiter function to limit the text length then got wordwrap to break it down over several lines, thanks for all your help :D

Solved

Nor 12-04-2007 07:03 PM

I personally dislike wordwrap because if your using html tags it trims the tags which i don't like. This would be a nice update to the function.

ReSpawN 12-04-2007 09:58 PM

There are a lot of scripts going arround, even one which defined the PIXELS of a character, like a is 4, and p is 3,9. So, you can define, into the function, how long you want your sentence to be. For example shortenCode($text, $pixels); Define yours, what ever you please.

Next, you can, if you want, define the cutter, as I like to call it, which ends the code with, for example "..." or "...<br /><br /><strong>Read More</strong>". Only "read more" of course, will act as a full link to the posted message.

It's a little bit overkill, but for those who want to be precise, should use that. If somebody is interested, I can find it (again). ;)


All times are GMT. The time now is 04:27 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0