PHP Determine Line Breaks

To see whitespace characters in php, use the following function:

function raw($str) {
    $str = str_replace(array("\t", "\r\n", "\r", "\n"),
                       array('\t', '\r\n', '\r', '\n'), $str);
}
// line endings are replaced with literal characters
$str = str_replace("\t", '\t', $str);
$str = str_replace("\r\n", '\r\n', $str);
$str = str_replace("\n", '\n', $str);
$str = str_replace("\r", '\r', $str);
echo $s;
 
// combined
$str = str_replace(array("\t", "\r\n", "\r", "\n"),
                   array('\t', '\r\n', '\r', '\n'), $str);
echo $s;
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment