Answers for "php remove line breaks from string"

PHP
0

revert local commit

$ git reset --hard HEAD~1
Posted by: Guest on March-03-2020
0

how remove \r\n from string in php

$text = preg_replace("/\r|\n/", "", $text);
Posted by: Guest on January-30-2021
1

php remove newline

//Replace the newline and carriage return characters
//using regex and preg_replace.
$text = preg_replace("/\r|\n/", "", $text);
Posted by: Guest on December-09-2020
1

php remove enter from string

$_result = trim(preg_replace('/\s+/', ' ', $original_text));
Posted by: Guest on April-28-2021
1

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));
Posted by: Guest on August-27-2020

Code answers related to "php remove line breaks from string"

Browse Popular Code Answers by Language