note 25385 added to function.var-dump
| From: | rudigier at noxx dot at | Date: | Sat, 21 Sep 2002 12:28:29 +0000 |
| Subject: | note 25385 added to function.var-dump | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37083@lists.php.net to get a copy of this message | ||
here's my improved version of svar_dump using tables :)
/* Sam Sep 21 12:52:26 CEST 2002 */
function test($vInput, $iLevel = 1)
{
$bg[1] = "#DDDDDD";
$bg[2] = "#C4F0FF";
$bg[3] = "#BDE9FF";
$bg[4] = "#FFF1CA";
$return = <<<EOH
<table border='0' cellpadding='5' cellspacing='1'
style='font-size:10px'>
<tr>
<td align='left' bgcolor="{$bg[$iLevel]}">
EOH;
if (is_int($vInput))
{
$return .= "int (<b>".intval($vInput)."</b>) </td>";
}
else if (is_float($vInput))
{
$return .= "float (<b>".doubleval($vInput)."</b>) </td>";
}
else if (is_string($vInput))
{
$return .= "string (" . strlen($vInput) . ") \"<b>" . $vInput .
"</b>\"</td>";
}
else if (is_bool($vInput))
{
$return .= "bool(<b>" . $vInput ? "true" : "false" .
"</b>)</td>";
}
else if (is_array($vInput))
{
$return .= "array count = [<b>" . count($vInput) . "</b>] dimension =
[<b>{$iLevel}</b>]</td></tr><tr><td>";
$return .= <<<EOH
<table border='0' cellpadding='5' cellspacing='1'
style='font-size:10px'>
EOH;
while (list($vKey, $vVal) = each($vInput))
{
$return .= "<tr><td align='left'
bgcolor='".$bg[$iLevel]."'><b>";
$return .= (is_int($vKey)) ? "" : "\"";
$return .= $vKey;
$return .= (is_int($vKey)) ? "" : "\"";
$return .= "</b></td><td
bgcolor='".$bg[$iLevel]."'>=></td><td
bgcolor='".$bg[$iLevel]."'><b>";
$return .= test($vVal, ($iLevel + 1)) . "</b></td></tr>";
}
$return .= "</table>";
}
else
{
$return .= "NULL</td>";
}
$return .= "</table>";
return $return;
}
#########################
<? echo test( var ) ?>
--
http://www.php.net/manual/en/function.var-dump.php
http://master.php.net/manage/user-notes.php?action=edit+25385
http://master.php.net/manage/user-notes.php?action=delete+25385
http://master.php.net/manage/user-notes.php?action=reject+25385