Search code examples
phparraysvar-dump

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


Solution

  • 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