My PHP_EOL is \"\\r\\n\", however, when I do print_r
on an array each new line has a \"\\n\" - not a \"\\r\\n\" - placed after it.
Any idea if it\'s pos
Question Is it possible to change the behavior of PHP's print_r function was marked was duplicated of this one . I'd like to answer more how is possible change the behavior of print_r. My propose is do another function with another name that do the print_r customized . And we just need replace print_r functions with print_r_pretty ...
function print_r_pretty($in, $saveToString = false) {
$out = print_r($in, true);
$out = str_replace("\n", "\r\n", $out);
switch ($saveToString) {
case true: return $out;
default: echo $out;
}
}
But line :
$out = str_replace("\n", "\r\n", $out);
can be replaced by another line that do another changes to print_r like this :
$out = explode("\n", $out, 2)[1];