note 25385 deleted from function.var-dump by sniper

From: Date: Sun, 28 Sep 2003 22:38:59 +0000
Subject: note 25385 deleted from function.var-dump by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57226@lists.php.net to get a copy of this message
Note Submitter: rudigier@noxx.at ---- 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 ) ?>

« previous php.notes (#57226) next »