2

How can I show these characters on a webpage?

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
  • Can you be a little more specific? How do you intent to show them? You're talking about actually having these characters in your text and translating or converting them into something that shows visually? – GalacticCowboy Feb 18 '10 at 14:08

2 Answers2

3
// An example to replace all newlines with their character equivalent
$value = preg_replace('/[\r\n]+/', '\n', $value);
echo htmlentities($value);
Yada
  • 30,349
  • 24
  • 103
  • 144
0

Can you not do the following...

<?php
echo "&#92;n"."\n";
echo "&#92;0"."\n";
echo "&#92;t"."\n";
echo "&#92;x0B"."\n";
echo "&#92;r"."\n";
?>

Expected Result:

\n
\0
\t
\x0B
\r

and that should just print to screen, since &#92; is the reference for a \ on web pages.

EDIT:

Looks like StackOverflow auto-changes &#92; to a \ when not marked as code!

Urda
  • 5,460
  • 5
  • 34
  • 47