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?
+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
2010-04-16 04:48:10
A:
couldnt you just do
foreach ($array as $structure=>$data){
echo $structure."=><br />";
}
Jamie
2010-04-16 04:49:35
+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
2010-04-16 05:18:20