📜  php 删除包含字符串的行 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:38.050000             🧑  作者: Mango

代码示例1
$rows = file("problem.txt");    
$blacklist = "foo|bar|lol";

foreach($rows as $key => $row) {
    if(preg_match("/($blacklist)/", $row)) {
        unset($rows[$key]);
    }
}

file_put_contents("solved.txt", implode("\n", $rows));