多くの文字列を含むテキスト ファイルを指定します。
たとえば、red applesを検索する場合、次のコード:
$search = "red apples";
$contents = file_get_contents("file.txt");
$pattern = "/^.*$search*\$/m";
preg_match_all($pattern, $contents, $matches);
implode("\n", $matches[0]);
は、(他の文字列と共に) 次のものを返します。
Plate with many red apples blah blah
同じ文字列を見つける必要がありますが、 apples redを検索します。それを行う方法はありますか?
ありがとう。