How to replace \t tab \n new line and \r carriage return in a string in PHP

1 Answer

0 votes
$s = "php\n\tpython\rc#\tc++\n";

$s = str_replace("\r", " " ,str_replace("\t", " ", str_replace("\n", " ", $s)));

echo $s;


   
/*
run:
    
php python c# c++

*/

 



answered Nov 21, 2017 by avibootz
...