Reputation: 1273
I need to analyze an object in my code, but when I do a var_dump (or print_r) it just prints the object out with no structure, for example:
[0]=> object(simple_html_dom_node)#2185 (9) { ["nodetype"]=> int(1) ["tag"]=> string(3) "div" ["attr"]=> array(1) { ["class"]=> string(36) "element element--collection internal" } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#2187 (
I need to see it in a more structured format so I can see what is going on, i.e.:
object(simple_html_dom_node)#2185 (9) {
["nodetype"]=> int(1)
["tag"]=> string(3) "div"
["attr"]=> array(1)
{
["class"]=> string(36) "element element--collection internal"
}
["children"]=> array(2) {
[0]=> object(simple_html_dom_node)#2187 (9)
Does anyone know how to do this?
Upvotes: 0
Views: 1687
Reputation: 782158
The format you want is actually how var_dump()
prints the object. The problem is that you're doing it in an HTML document, and the browser reformats it.
If you put it inside a <pre>
tag, the browser will leave the formatting alone. So:
echo "<pre>"; var_dump($object); echo "</pre>";
Upvotes: 1
Reputation:
Try using var_export()
, this function will give you a more readable structure of the object or data.
Upvotes: 0