什么是获取两个字符串之间的内容的最佳方式,例如
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?
提前致谢!