note 40651 added to function.var-dump

From: Date: Wed, 10 Mar 2004 17:20:10 +0000
Subject: note 40651 added to function.var-dump
Groups: php.notes 
Request: Send a blank email to php-notes+get-66574@lists.php.net to get a copy of this message
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; } ---- Manual Page -- http://www.php.net/manual/en/function.var-dump.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40651 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40651&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40651&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66574) next »