function print_r(arr, level) {
var print_red_text = "";
if(!level) level = 0;
var level_padding = "";
for(var j=0; j<level+1; j++) level_padding += " ";
if(typeof(arr) == 'object') {
for(var item in arr) {
var value = arr[item];
if(typeof(value) == 'object') {
print_red_text += level_padding + "'" + item + "' :\n";
print_red_text += print_r(value,level+1);
}
else
print_red_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
else print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
return print_red_text;
}
/*пример вызова*/
alert(print_r(array));
/* или */
console.log(print_r(obj))
function print_r(arr, level) {
var print_red_text = '';
var level_padding = '';
var dopPadding = ' ';
if(!level)
level = 0;
for(var j=0; j<level+1; j++) {
level_padding += " ";
}
if (level > 1) {
level_padding += dopPadding;
}
print_red_text = "Array \n" + (level > 0 ? level_padding + '' : '') + "(\n";
if(typeof(arr) == 'object') {
for(var item in arr) {
var value = arr[item];
if (typeof(value) == 'object') {
print_red_text += (level > 0 ? level_padding + '' : '') + " [" + item + "] => " + print_r(value, level+1) + "\n";
} else {
print_red_text += (level > 0 ? level_padding + '' : '') + " [" + item + "] => " + value + "\n";
}
}
}
else {
print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
}
print_red_text += (level > 0 ? level_padding : '') + ")\n";
return print_red_text;
}