Trevor
Trevor

Reputation: 2932

Any way to make PHP var_dump display deeper nested arrays?

I am working on a script that takes uploaded INI files and converts them to a database. The INI files are quite poorly written and created loops inside themselves. I am first converting the INIs into arrays, nested in the way that they will be inserted into database tables. But this means I am having 4 levels and deeper of arrays. More than var_dump will show.

echo "<pre>";
print_r(array);
echo "</pre>";

works, but it's not nicely formatted, and it's cumbersome, so I am hoping var_dump can be modified somehow to be allowed to go deeper. Is there such an option?

Thanks

-Edit, found the answer, it was a duplicate. Posting as a clarification to other searchers. Open your php.ini, find the section called [xdebug] add this to the end of the section xdebug.var_display_max_depth=-1

Upvotes: 1

Views: 2613

Answers (2)

user1681832
user1681832

Reputation: 41

Or simply add this at your script:

ini_set('xdebug.var_display_max_depth', 99);

Upvotes: 4

mehulmpt
mehulmpt

Reputation: 16597

Keep in mind if you have xdebug installed it will limit the var_dump() output of array elements and object properties to 3 levels deep.

To change the default, edit your xdebug.ini file and add the folllowing line:

xdebug.var_display_max_depth=n

where n is your max level.

More information here: http://www.xdebug.org/docs/display

Upvotes: 2

Related Questions