PHP - how can I show \n \0 \t \x0B \r

Phill Pafford picture Phill Pafford · Feb 18, 2010 · Viewed 7.2k times · Source

How can I show these characters on a webpage?

Answer

Yada picture Yada · Feb 18, 2010
// An example to replace all newlines with their character equivalent
$value = preg_replace('/[\r\n]+/', '\n', $value);
echo htmlentities($value);