Posted By

wintondeshong on 07/20/07


Tagged

textmate actionscript array printr


Versions (?)

print_r


 / Published in: ActionScript
 

  1. private function print_r( obj, indent ) {
  2.  
  3. if (indent == null) indent = "";
  4. var out = "";
  5. for ( item in obj ) {
  6. if (typeof( obj[item] ) == "object" )
  7. out += indent+"[" + item + "] => Object\n";
  8. else
  9. out += indent+"[" + item + "] => " + obj[item]+"\n";
  10. out += print_r( obj[item], indent+" " );
  11. }
  12. return out;
  13. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: HerrO on June 7, 2009

you should modify it like this to use it in AS3:

    private function print_r( obj, indent = null ) {

        if (indent == null) {
            indent = "";
        }
        var out = "";
        for (var item in obj) {
            if (typeof( obj[item] ) == "object" ) {
                out += indent+"[" + item + "] => Object\n";
            } else {
                out += indent+"[" + item + "] => " + obj[item]+"\n";
            }
            out += print_r( obj[item], indent+"   " );
        }
        return out;
    }

You need to login to post a comment.