Kri*_*eth 3 php pattern-matching
$file = file_get_contents("http://www.bigsite.com");
Run Code Online (Sandbox Code Playgroud)
我怎样才能从$file包含单词"hello"的字符串中删除所有行?
小智 10
$file = file_get_contents("http://www.bigsite.com");
$lines = explode("\n", $file);
$exclude = array();
foreach ($lines as $line) {
if (strpos($line, 'hello') !== FALSE) {
continue;
}
$exclude[] = $line;
}
echo implode("\n", $exclude);
Run Code Online (Sandbox Code Playgroud)