Posts Tagged Under print_r dalam javascript

November 18th, 2009

print_r dalam javascript

Fungsi Javascript yang fungsinya seakan fungsi print_r PHP

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}

Selamat mencuba.

Posted in javascript
By
read more
Forum Tutorial php,mysql,javascript,css,html bahasa melayu

Tutorial php,mysql,javascript,css,html bahasa melayu