splitting up long posts w/o splitting html

From: Date: Sat, 01 Jul 2000 19:43:45 +0000
Subject: splitting up long posts w/o splitting html
Groups: php.general 
Request: Send a blank email to php-general+get-4335@lists.php.net to get a copy of this message
All - I'm allowing users to submit blurbs to my site through a form and want to split the long posts. Users are allowed to post basic html (<a>,<i>,<b><ul><ol><li><p><br>) and the rest is stripped off using strip_tags(). So right now I have something like this: // Get the POST data and strip off unwanted HTML $keep_html = "<a>,<i>,<b>,<ul>,<ol>,<li>,<p>,<br>" $blurb = strip_tags($HTTP_POST_VARS["blurb"],$keep_html); // If magic_quotes_gpc is enabled swap \" back to " and so forth if (get_magic_quotes_gpc()) { $blurb = stripslashes($blurb); } // For the summmary only keep the first 500 chars of $blurb. Make sure // the break happens at the end of a word to. if (strlen($blurb) > 500) { // finds the first "word boundry" somewhere after 500 chars $break_point = strpos($blurb," ",500); if ($break_point === false) { $summary = $blurb; } else { // Chars 0 to $break_point are a summary of the $blurb data $summary = substr($blurb,0,$break_point)." ..." ; } } My problem is that if the 'break point' for the summary is for example after the word "text" and before the word "that" in the following sentance: <B>Some text that breaks</B> may also break HTML formatting. Then the HTML runs the risk of being broken as well. I need someway to ensure that the break point I've choosen won't also break HTML formatting or even worse hyperlinks. Any thoughts on how to do this? -- Scott

« previous php.general (#4335) next »