Skip to content

Instantly share code, notes, and snippets.

@tbleckert
Created August 30, 2010 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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