tags:

views:

46

answers:

4

I was wondering if there is a way to print just the structure of the array without the contents. I generally use print_r to examine the structure but because my array contains some binary data, I'd rather not use this. Any suggestions?

A: 

write your own recursive function emulating print_r?

Col. Shrapnel
+6  A: 
<?php
    function print_no_contents($arr) {
        foreach ($arr as $k=>$v) {
            echo $k."=> ";
            if (is_array($v)) {
                echo "\n";
                print_no_contents($v);
            }
            else echo "[data]";
            echo "\n";
        }
    }
?>

*didn't test this, but should get you started.

Austin Hyde
A: 

couldnt you just do

foreach ($array as $structure=>$data){
  echo $structure."=><br />";
}
Jamie
+1  A: 

I like to use xdebug's var_dump() overload for all of my variable snooping. You can provide it with an ini setting to truncate the values that are dumped out, and it provides some sane limites to begin with (though I'm not sure what it typically does with binary data).

ini_set('xdebug.var_display_max_data', 0);
var_dump($your_variable);

You can download it from http://xdebug.org/

banzaimonkey