note 25794 deleted from function.var-dump by sniper

From: Date: Sun, 28 Sep 2003 22:38:55 +0000
Subject: note 25794 deleted from function.var-dump by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57225@lists.php.net to get a copy of this message
Note Submitter: roseofchaos at spam d0t myrealbox () com ---- Sometimes its hard to read the output of var_dump, so I created a function that looks a LOT better. You can use it like: vardump($var); and it'll be printed, or vardump($var, 1); and it'll be returned.. Note that it IS formatted in HTML. I should also note that it dosn't do too much for non-arrays, but add a little font to it. function vardump($in, $return = 0) { $type = gettype($in); ob_start(); var_dump($in); $in = ob_get_contents(); ob_end_clean(); if($type == 'array') { // Split into an array $in = explode("\n", $in); // Do the br'in $x = 0; foreach($in as $value) { if($x%2 == 0) { $in[$x] .= "<br>\n"; }$x++; } // Put it back together $ins = NULL; foreach($in as $value) { $ins .= $value; } if($return == 1) { return '<tt>' . $ins . '</tt>'; } else { echo '<tt>' . $ins . '</tt>'; } } else { if($return == 1) { return '<tt>' . $in . '</tt>'; } else { echo '<tt>' . $in . '</tt>'; } } }

« previous php.notes (#57225) next »