Skip to content

Instantly share code, notes, and snippets.

@tbleckert
Created August 30, 2010 12:50
Show Gist options
  • Save tbleckert/557357 to your computer and use it in GitHub Desktop.
Save tbleckert/557357 to your computer and use it in GitHub Desktop.
function print_r(arr) {
if( arr.constructor == Array || arr.constructor == Object ) {
document.write('<ul>');
for( var p in arr ) {
if( arr[p].constructor == Array || arr[p].constructor == Object ) {
document.write('<li>['+p+'] => '+typeof(arr)+'</li>');
document.write('<ul>');
print_r(arr[p]);
document.write('</ul>');
} else {
document.write('<li>['+p+'] => '+String(arr[p]).replace(/<\/?[^>]+>/gi, '')+'</li>');
}
}
document.write('</ul>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment