Show me hidden Characters

I was just needing to be able to see what the hidden characters were at the end of a string so I could know what to remove and found this nifty ‘trick’ to see them. If you know of any other/better ways please post. Just echo the string with json_encode. You will be able to see all the \n and \r\n hidden characters.

[php]$str = “…”;
echo json_encode($str);[/php]

Yours is by far the simplest way.

[php]$string = “My name is
elmo\r\n”;
for( $i = 0; $i < strlen($string); $i++) {
echo “

” . json_encode(chr(ord($string[$i]))) . " : {$string[$i]}: " . ord($string[$i]) . “

”;
}[/php]

This uses yours and a concoction to see the ASCII value.

Sponsor our Newsletter | Privacy Policy | Terms of Service