Hello ,
First thing is change variable name buffer to any other name or imm. assign buffer value to other variable .
second thing is preg_match_all is storing values in Multiple array not single array .
Try following code its working ..
$buffer = "<html><head><title>something</title></head><body>hello, this is some stupid text<!-- start forecast by LOC code (smb) --> this is the text I would like to extract <!-- end forecast by LOC code (smb) --> and this is some more stupid text <br><i>containing HTML and stuff, because I got it from a HTTP request</body></html>";
$myvar = $buffer;
echo htmlspecialchars($buffer);
echo "<br><br><hr><br><hr><br><br>";
// begin = "<!-- start forecast by LOC code (smb) -->"
// end = "<!-- end forecast by LOC code (smb) -->"
$bericht = preg_match_all("/.start forecast(.)end forecast.*/", "AAAAAA\1", $buffer);
echo htmlspecialchars($bericht);
echo "<hr><hr>";
//preg_match_all('/<title>(.?)title>/', $buffer, $aMatches);
preg_match_all("/(<([\w]+)[>]>)(.*)(<\/\2>)/",$myvar, $aMatches);
for ($i=0; $i< count($aMatches[0]); $i++)
{
echo "Matched text: ".$aMatches[0][$i]."<br>";
echo "part 1: ".$aMatches[1][$i]."<br>";
echo "part 2: ".$aMatches[3][$i]."<br>";
echo "part 3: ".$aMatches[4][$i]."<br><br>";
}