My account: Login | Sign Up
Loading...

Truncate string to last full stop | Thread profile

Thread profile page for "Truncate string to last full stop" on http://www.sitepointforums.com. This report page is a snippet summary view from a single thread "Truncate string to last full stop", located on the Message Board at http://www.sitepointforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity, which are reported in a table below. Additional thread profile information is also shown in the following ways:

1) Top Contributing Authors
2) Related Threads on "eBay Auctions"
3) Related Threads on Other Sites

Warning: These statistics are generated using 'best efforts' and can experience delays and reporting errors at times. Please note that such statistics do not constitute a thread's popularity and/or exact posting volumes at any given reporting period.

Title: Truncate string to last full stop
Site: SitePoint : New Articles, Fresh Thinking for Web Developers and Designers  SitePoint : New Articles, Fresh Thinking for Web Developers and Designers - site profile
Forum: PHP   PHP   - forum profile
Total authors: 2 authors
Total thread posts: 4 posts
Thread activity: no new posts during last week
Domain info for: sitepointforums.com

Thread posts in Truncate string to last full stop:

1. 
Started 2 years, 1 month ago (2006-07-13 10:06:00)  by Mandes
Hi All Im sure someone will have this in a library somewhere. I'm printing out a string of text, but when printing only have a certain area in which I can put said text, I currently truncate the text string and add a few dots if it overspills the area, but this looks a bit 'unfinished' on the printed document. What Id like to do is truncate the text back to the last full stop (period), Im ...
Size: 509 bytes
Customize:  Customize "Truncate string to last full stop :: PHP   :: SitePoint : New Articles, Fresh Thinking for Web D..."
2. 
Started 2 years, 1 month ago (2006-07-13 10:20:00)  by aamonkey
are you willing to live with situations where the period is part of an abbreviation? also, what about sentences that end with ! or ? might get you close: PHP Code: function abbr($str, $maxLen) { if (strlen($str) > $maxLen && $maxLen > 1) { preg_match("#^.{1,".$maxLen."}\.#s", $str, $matches); return $matches[0]; } else { return $str; } }
Size: 382 bytes
Customize:  Customize "<b>Reply 1</b>: Truncate string to last full stop :: PHP   :: SitePoint : New Articles, Fresh Thinking for Web D..."
3. 
Started 2 years, 1 month ago (2006-07-13 10:32:00)  by Mandes
I take your point (pun intended), adding the ! and ? to the . should be quite easy. The text is actually an abbrievated description of an item, entered into a DB for this sole purpose, it would be very unusual for abbrieated words to be in this description. And if one was found it could easily be changed by the operator before printing the document. edit: Thanks for the code I'll have a play ...
Size: 405 bytes
Customize:  Customize "<b>Reply 2</b>: Truncate string to last full stop :: PHP   :: SitePoint : New Articles, Fresh Thinking for Web D..."
4. 
Started 2 years, 1 month ago (2006-07-13 10:57:00)  by Mandes
Works like a charm, thanks.
Size: 27 bytes
Customize:  Customize "<b>Reply 3</b>: Truncate string to last full stop :: PHP   :: SitePoint : New Articles, Fresh Thinking for Web D..."
 

Top contributing authors for Truncate string to last full stop

Name Posts
Mandes 3
aamonkey 1