note 42172 deleted from function.var-dump by tomsommer

From: Date: Fri, 07 May 2004 18:20:08 +0000
Subject: note 42172 deleted from function.var-dump by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69321@lists.php.net to get a copy of this message
Note Submitter: Ruben Barkow(mail->@web.de) ---- if you want to see the content of an array in a well readeable html table use this script: useage: vardump($bla "bla"); // (second arg is optional) or echo svar_dump($bla, 1, "bla"); // (second and third arg is optional) function vardump($a, $name=""){ echo svar_dump($a, 1, $name); } function svar_dump($vInput, $iLevel = 1, $name="") { $bg[1] = "#DDDDDD"; $bg[2] = "#C4F0FF"; $bg[3] = "#00ffff"; $bg[4] = "#FFF1CA"; $bg[5] = "white"; $bg[6] = "#BDE9FF"; $bg[7] = "#aaaaaa"; $bg[8] = "yellow"; $bg[9] = "#eeeeee"; $return = <<<EOH <!-- >">'></select></textarea> --> <table border='0' cellpadding='0' cellspacing='1' style='font-size:11px'> <tr> <td align='left' bgcolor="{$bg[$iLevel]}" style='font-size:11px'> EOH; if($name) $return .= "<b>$".$name."</b> : "; 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>" . nl2br(str_replace(" ", "&nbsp;", htmlspecialchars($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 style='font-size:11px'>"; $return .= <<<EOH <table border='0' cellpadding='0' cellspacing='1' style='font-size:11px'> EOH; while (list($vKey, $vVal) = each($vInput)){ $return .= "<tr><td align='left' bgcolor='".$bg[$iLevel]."' valign='top' style='font-size:11px'><b>"; $return .= (is_int($vKey)) ? "" : "\""; $return .= $vKey; $return .= (is_int($vKey)) ? "" : "\""; $return .= "</b></td><td bgcolor='".$bg[$iLevel]."' valign='top' style='font-size:11px'>=></td><td bgcolor='".$bg[$iLevel]."' style='font-size:11px'><b>"; $return .= svar_dump($vVal, ($iLevel + 1)) . "</b></td></tr>"; } $return .= "</table>"; } else { $return .= "NULL</td>"; } $return .= "</table>"; return $return; }

« previous php.notes (#69321) next »