Re: Trimming Text

From: Date: Fri, 15 Jul 2005 15:03:15 +0000
Subject: Re: Trimming Text
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-218758@lists.php.net to get a copy of this message
Hello André, Friday, July 15, 2005, 4:24:23 PM, you wrote: AM> I am trying to trim some text containing HTML tags. What I want to AM> do is to trim the text without trimming the tags or html entities AM> like &nbsp; and such, wich completelly break the design. The problem as I see it, is that while it's easy to trim some text and then check to see if you were inside an HTML tag or not, it becomes MUCH harder to check if you were inside nested tags (for example <strong><em>) If there are no nested tags then it's much easier.. just trim the string at X characters and then search for the last occurrence of a '>' and the last occurance of '<' - if the first is LESS than the second value, then you're in the middle of a tag. This of course doesn't handle nested tags. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services "I do not fear computers. I fear the lack of them." - Isaac Asimov

« previous php.general (#218758) next »