Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If i do print_r in PHP, it prints the array in junk

Tags:

php

How can I print the array in a Tree-like format--making it easier to read?

like image 558
TIMEX Avatar asked Oct 03 '09 22:10

TIMEX


2 Answers

Try:

<pre><?php print_r($var); ?></pre>

It will give the proper tree structure that HTML's whitespace policy trims out.

like image 69
Robert K Avatar answered Nov 01 '22 16:11

Robert K


Are you wrapping the output in <pre> tags? That should get you pretty decent output, because it will show the spaces. Another option would be to install the xdebug extension, which then can replace var_dump so that it generates more-readable HTML output.

like image 32
davidtbernal Avatar answered Nov 01 '22 17:11

davidtbernal