TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-29-2007, 11:58 PM   #1 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Help 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!
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 11-30-2007, 12:07 AM   #2 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

http://php.net/wordwrap should help.
Haris is offline  
Reply With Quote
Old 11-30-2007, 02:33 AM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Yep, the wordwrap function along with the concatenation for the ellipsis would do it, no?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-30-2007, 03:45 PM   #4 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default

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
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 12-04-2007, 07:03 PM   #5 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

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.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 12-04-2007, 09:58 PM   #6 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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). ;)
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:43 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design