Printing an array structure without its contents?

I was wondering if there is a way to print only the structure of the array with no content. I usually use print_r to examine the structure, but since my array contains some binary data, I would rather not use this.

+5
source share
4 answers
<?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";
        }
    }
?>

* not tested this, but you need to get started.

+12
source

Could you just do

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

xdebug var_dump() overload . ini, , , ( , ).

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

http://xdebug.org/

+1

​​

        echo printArray($your_array);

        function printArray($a,$return=true) {
                   if(!$return)
                      echo "<pre style=\"font-size:12px;\">".print_r($a,true)."</pre>";
                   else
                       return "<pre style=\"font-size:12px;\">".print_r($a,true)."</pre>";
        }
+1

All Articles