----- Original Message ----- > From: Stuart <stuttle@xxxxxxxxx> > > You can't have any extra info in a closing HTML tag. This > > problem is > > usually handled using comments. Something like the following... > > > > <div id="divContent"> > > <!-- content begin --> > > sofihsod hiosdh sdh gus us u sg > > <!-- content end --> > > </div> > > > > You then just start with you see the begin comment and stop > when you > > hit the end comment. > --------- Hmm, they are stripping out the tags before looking at the words, so didn't work quite as I originally thought. The solution seems to be to explode the string based on the entire comment before doing the word-by-word storing. I wrote up the following test code that seems to work and handles any string or error I could think of. Am wondering if this is good or is there better/more efficient code? <?php function contentString($pString, $pStart, $pStop){ echo "$pString<br />"; $finalArray = array(); $finalString = ""; $exploded1 = explode($pStart, $pString); // makes array $exploded1 for ($i=1; $i<count($exploded1); $i++) // ignore first item (0) in array { $exploded2 = explode($pStop, $exploded1[$i]); array_push($finalArray, $exploded2[0]); // array of just the wanted sections } foreach ($finalArray as $value3) { $finalString .= $value3 . " "; // " " ensures separation between substrings } $finalString = trim($finalString); // trim any extra white space from beginning/end echo $finalString; echo "<br /><br />"; } // TEST $startTerm = "START"; $stopTerm = "STOP"; // test typical string $theString = "one two START three four STOP five six START seven eight STOP nine ten"; contentString($theString, $startTerm, $stopTerm); // outputs "three four seven eight" // test string with immediate START $theString = "START one two STOP three four START five six STOP seven eight START nine ten"; contentString($theString, $startTerm, $stopTerm); // outputs "one two five six nine ten" // test string with "error" (2 STARTS) $theString = "START one two START three four STOP five six START seven eight STOP nine ten"; contentString($theString, $startTerm, $stopTerm); // outputs "one two three four seven eight" // test string with no space between separators and real content $theString = "STARTone twoSTOP three four STARTfive sixSTOP seven eight STARTnine ten"; contentString($theString, $startTerm, $stopTerm); // outputs "one two five six nine ten" ?> Any thoughts/suggestions? Thanks! George