Split a string on a space, not in side an HTML tag.

From: Date: Mon, 23 Feb 2004 11:10:17 +0000
Subject: Split a string on a space, not in side an HTML tag.
Groups: php.general 
Request: Send a blank email to php-general+get-178522@lists.php.net to get a copy of this message
Hi, I'm trying to get a 500 character split of a string, I only want about the fist 500 characters, I would like to split on a space, which I have managed to do so far, but I would also like the split to not take place inside an HTML tag, so that I don't end up with weird looking pages. I was trying to use strip_tags() error checking to tell me whether I my string was valid html or not. If it's not valid html then I would like to split before that part of the html begins. Possibly even as simply as removing the last 10 characters (to the nearest space) until I get valid HTML. Can anyone help me get a way to split my text at around the 500 character mark without breaking any HTML which may be inside the string I am displaying on the page? Also, if you're interested in the strip_tags() problem I was speaking about then take a look at: http://better.domain.name/php/strip.php there is a link to the source on the page. Regards,
        Stuart Gilbert.


« previous php.general (#178522) next »