Matthew, On Tue, Oct 28, 2008 at 1:12 PM, Matthew Weier O'Phinney <[EMAIL PROTECTED]>wrote:
> -- Bradley Holt <[EMAIL PROTECTED]> wrote > (on Tuesday, 28 October 2008, 12:29 PM -0400): > > Is there a simple way in ZF to truncate a string? I searched and didn't > find > > any talk of a ZF specific component for this. I also looked at the list > of > > standard filter classes and didn't see anything there either. I know > there are > > tons of possible ways to do this - I'm just surprised there isn't > anything in > > ZF yet so perhaps I'm just not looking in the right place. > > You're looking for Zend_Filter_StringTrim -- which can be used in the > form classes as well. Maybe I'm just slow today, but I'm not sure how Zend_Filter_StringTrim would be used to truncate a string to a given character or word length. I thought it simply removed given characters from the beginning and end of a string. For example, I want to truncate the following: The quick brown fox jumped over the lazy sleeping dog. to 30 characters: The quick brown fox jumped ove or to 30 characters, but the closest whole word: The quick brown fox jumped or to 6 words (instead of characters): The quick brown fox jumped over Of course, there are probably other features that may be useful too. Is this something that can be done in Zend_Filter_StringTrim or using another ZF component? There are numerous ways to do this in PHP directly (so no need for anyone to post those here) but I was just curious if ZF had a clean and simple way to do this. Thanks, Bradley > > > -- > Matthew Weier O'Phinney > Software Architect | [EMAIL PROTECTED] > Zend Framework | http://framework.zend.com/ > -- Bradley Holt [EMAIL PROTECTED]