]*?)?>)(.*?)($open|$close)#is",substr($sample_html, $offset), $matches)) { if (!preg_match("#<\s*/\s*p\s*>#is",$matches[3])) { $cutpos = $offset + strlen($matches[1]) + strlen($matches[2]) + strlen($matches[4]); $sample_html = substr_replace($sample_html, "
", $cutpos, 0); $offset = $cutpos+4; } else { $offset += strlen($matches[1])+1; }; }; return $sample_html; }; ?>