Public feed
#378836
<?php
function returnStringRST($text, $openingMarker, $closingMarker) {
$openingMarkerLength = strlen($openingMarker);
$closingMarkerLength = strlen($closingMarker);
$result = "";
$position = 0;
if(($position = strpos($text, $openingMarker, $position)) !== false) {
if (($closingMarkerPosition = strpos($text, $closingMarker, $position)) !== false) {
$replaceThis = substr($text, $position-$openingMarkerLength, $closingMarkerPosition - $closingMarkerLength);
$text = ereg_replace($replaceThis, '', $text);
returnStringRST($text, "<!--", "-->");
}
}
return $text;
}
$testText = "Before comment <!-- comment--> before comment2 <!-- comment2 --> after comment2";
$result = returnStringRST($testText, "<!--", "-->");
print($result);
?>