Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php remove line if it contains string

$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("
", $rows));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #remove #line #string
ADD COMMENT
Topic
Name
6+5 =