如何找到文檔上的字符串,然後回顯字符串?如何在文檔上查找字符串,然後回顯字符串?
例如,
文件:
blah blah result.php?whatiwanttoecho blah
或:
blahhh result.php?whatiwanttoecho blah blah blah
總是會有「result.php?之前我想回聲。
最終的結果我在尋找:
$doc = "./doc.txt";
$doccontents = file_get_contents($file);
然後,我需要有最終結果幫助代碼:
$result = 'whatiwanttoecho';
echo $result;
希望這是有道理的。謝謝(:
如果STRI ng以'result.php?whatiwanttoecho'結尾,你的正則表達式不匹配(另見[this link](http://ideone.com/FC4p1))。 – scessor
我已更新! – HanhNghien
對不起,但與CoursesWeb解決方案相反,如果'result.php?whatiwanttoecho'位於字符串的末尾,您的regex仍然不匹配(另請參閱[此鏈接](http://ideone.com/jer3B))。 – scessor