I've got nothing better to do on my friday night, so i made the function for you:
function GetContents ($s, $open_tag, $close_tag) {
$m = '/' . $open_tag . '(.*?)' . $close_tag . '/is';
preg_match($m, $s, $r);
if (isset($r[1])) {
return $r[1];
} else {
return false;
}
}
$txt = "This is a test test test test test, a test. Here is some more testing: <! -- myComment -->
usual stuff i want in a string
nothing much but please help me <! -- endcomment --> followed by some testing and some other crap";
$x = GetContents($txt, "<! -- myComment -->", "<! -- endcomment -->");
if (!$x) {
echo("Pattern was not found.");
}
echo($x);
obviously, only the first part is the function. the rest is just an example of how it is used. If you have any problems, just reply to this thread, or IM me through AOL (Examancer).