php remove line breaks from string code example

Example 1: how remove \r\n from string in php

$text = preg_replace("/\r|\n/", "", $text);

Example 2: remove line break html php

preg_replace( "/\r|\n/", "", $yourString );

Example 3: php remove enter from string

$_result = trim(preg_replace('/\s+/', ' ', $original_text));

Example 4: 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("\n", $rows));