note 40651 deleted from function.var-dump by victor
| From: | victor@php.net | Date: | Tue, 23 Mar 2004 19:59:34 +0000 |
| Subject: | note 40651 deleted from function.var-dump by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67072@lists.php.net to get a copy of this message | ||
Note Submitter: martin swiech
----
If you want to save variable informations to other variable, you may use this little function with
global variable:
$var2stringdeep=0;
function var2string($variable) {
global $var2stringdeep;
$retval="";
for ($i=0;$i<$var2stringdeep;$i++) $retval.="\t";
if (is_int($variable)) $retval.="int(".$variable.")\n";
elseif (is_float($variable)) $retval.="float(".$variable.")\n";
elseif (is_bool($variable))
$retval.="boot(".($variable?"true":"false").")\n";
elseif (is_string($variable)) $retval.="string(".strlen($variable).")
\"".$variable."\"\n";
elseif (is_array($variable)) {
$retval .= "array(".sizeof($variable).") {\n";
$var2stringdeep++;
foreach ($variable as $klic => $hodnota) {
for ($i=0;$i<$var2stringdeep;$i++) $retval.="\t";
$retval .= "[".$klic."]=>\n";
$retval .= var2string($hodnota);
}
$var2stringdeep--;
for ($i=0;$i<$var2stringdeep;$i++) $retval.="\t";
$retval .= "}\n";
}
elseif (is_object($variable)) $retval.="OBJECT\n";
elseif (is_resource($variable)) $retval.="RESOURCE\n";
elseif (is_callable($variable)) $retval.="CALLABLE\n";
elseif (is_null($variable)) $retval.="NULL\n";
else $retval.="not identified\n";
return $retval;
}