Using print_r
, var_dump
or var_export
should do it pretty nicely if you look at the result in view-source mode not in HTML mode or as @Joel Larson said if you wrap everything in a <pre>
tag.
print_r
is best for readability but it doesn't print null/false values.
var_dump
is best for checking types of values and lengths and null/false values.
var_export
is simmilar to var_dump
but it can be used to get the dumped string.
The format returned by any of these is indented correctly in the source code and var_export
can be used for logging since it can be used to return the dumped string.
Use the xdebug plug-in for PHP this prints var_dump
s as HTML formatted strings not as raw dump format and also allows you to supply a custom function you want to use for formatting.