note 25794 added to function.var-dump

From: Date: Sun, 06 Oct 2002 21:17:41 +0000
Subject: note 25794 added to function.var-dump
Groups: php.notes 
Request: Send a blank email to php-notes+get-37722@lists.php.net to get a copy of this message
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>'; } } } -- http://www.php.net/manual/en/function.var-dump.php http://master.php.net/manage/user-notes.php?action=edit+25794 http://master.php.net/manage/user-notes.php?action=delete+25794 http://master.php.net/manage/user-notes.php?action=reject+25794

« previous php.notes (#37722) next »