I'm trying to debug a drupal 7 site and print_r() the $variables variable, but its HUGE and crashes certain pages when there is alot of data in it. Is there a way to only output the first level of the array without outputting everything inside of it?
Devel is a great tool for debugging. It comes with
krumo() function which works similar to
print_r() but doesn't output everything, only up to certain depth (I think 3 or 4 levels).
I faced a similar issue and found a raw solution, not very elegant nor easily usable in all cases, but it might help you:
- First use
- Look at the result to locate which keys match your needs.
- Then for each one, say
- And if it's too heavy again, go to #1 replacing
$variables[$var_x])... and so on!