Public feed
#378839
1.
<?php
2.
3.
function returnStringRST($text, $openingMarker, $closingMarker) {
4.
$openingMarkerLength = strlen($openingMarker);
5.
$closingMarkerLength = strlen($closingMarker);
6.
7.
$result = "";
8.
$position = 0;
9.
10.
if(($position = strpos($text, $openingMarker, $position)) !== false) {
11.
12.
if (($closingMarkerPosition = strpos($text, $closingMarker, $position)) !== false) {
13.
$replaceThis = substr($text, $position-$openingMarkerLength, $closingMarkerPosition - $closingMarkerLength);
14.
$text = ereg_replace($replaceThis, '', $text);
15.
returnStringRST($text, "<!--", "-->");
16.
17.
}
18.
}
19.
return $text;
20.
}
21.
22.
23.
$testText = "Before comment <!-- comment--> before comment2 <!-- comment2 --> after comment2";
24.
$result = returnStringRST($testText, "<!--", "-->");
25.
print($result);
26.
27.
?>