2つの文字列の間のコンテンツを取得するための最良の方法は何ですか。
ob_start();
include('externalfile.html'); ## see below
$out = ob_get_contents();
ob_end_clean();
preg_match('/{FINDME}(.|\n*)+{\/FINDME}/',$out,$matches);
$match = $matches[0];
echo $match;
## I have used .|\n* as it needs to check for new lines. Is this correct?
## externalfile.html
{FINDME}
Text Here
{/FINDME}
何らかの理由で、これは私のコードのある場所では機能し、別の場所では機能しないようです。私はこれを正しい方法で行っていますか?それとももっと良い方法はありますか?
また、出力バッファはこれまたはfile_get_contentsを実行する方法ですか?
前もって感謝します!