Is there a way to see invisible characters like whitespace, newlines, and other non-printing characters in a manner like print_r() ?
Reason is there is some sort of character in my array that I can't see and breaking things.
Object Object ( [name] => name [numbers] => Array ( [0] => 123 [1] => 456 [2] => 789 ) [action] => nothing )
See the weird whitespace between [0] and [1]? When printing out [0] a newline gets printed as well. But no where do I assign a newline to [0] so I'm quite confused.
Is there a built in function in php that's like show_invisible(Object->numbers[0])
and it will show 123\n
or similar?
To show non-printing characters in Word, click the “Home” tab in the Ribbon. Then click the “Show/Hide Non-Printing Characters” button in the “Paragraph” button group.
There is actually a truly invisible character: U+FEFF . This character is called the Byte Order Mark and is related to the Unicode 8 system.
Declare @nl Char(2) = char(13) + char(10) Declare @tab Char(1) = char(9) etc... Then you can use those declared variables anywhere in the rest of the proc without loss of clarity...
To see all the invisible characters not only \r
, \n
etc... It's good to see json_encode
ed version and everything is clear:
$str = "..."; echo json_encode($str);
You could probably list all the control characters out, but try this for a quick fix ?
PHP - print string with control characters
It's a simple str_replace("\n",'\n',$string)
kind of fix, but you could probably adapt the solution for a function callback on the array to convert those characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With