Search
 
SCRIPT & CODE EXAMPLE
 

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));
Comment

PREVIOUS NEXT
Code Example
Php :: left join in laravel 
Php :: route params link laravel 
Php :: how to use multiple where condition in codeigniter 
Php :: ctrl + d in vscode in phpstorm 
Php :: laravel collect where not 
Php :: remove action from theme wordpress 
Php :: loop object property laravel 
Php :: php mysql get last inserted id 
Php :: bin to dec php 
Php :: laravel string capitalize in view 
Php :: php routing 
Php :: aws s3 laravel package 
Php :: make a object php 
Php :: image uploading and validation php 
Php :: change woocommerce return to shop link 
Php :: mysqli real escape string php 
Php :: google translate api php 
Php :: woocommerce get product categories 
Php :: Format and show date PHP 
Php :: laravel seed 
Php :: laravel migration two primary key 
Php :: file to binary php 
Php :: php top frameworks 
Php :: woocommerce get variation price range 
Php :: laravel object to array 
Php :: php get url 
Php :: linux delete php sessions 
Php :: php controller 
Php :: how to change date formate in php 
Php :: parameterized function in php 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =