note 13578 deleted from function.var-dump by jimw

From: Date: Sat, 08 Dec 2001 23:58:56 +0000
Subject: note 13578 deleted from function.var-dump by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22403@lists.php.net to get a copy of this message
There is a problem with recursivity, when you are using var_dump on \$GLOBALS. (Tested on PHP 4.0 - Win32 Distribution) I wrote this functions to solve it. - - <?php $GLOBALS[is_included][echo_array]=(true); function echo_array($a,$key="") {$l=0; echo "<CODE>\nArray <B>".$key."</B><BR>\n"; echo_array_self($a,$key,$l); echo "\n</CODE>"; } function echo_array_self($a,$key="",$l=1) {while(list($k,$v)=each($a)) {for($i=0;$i<$l;$i++){echo " |";} echo " +"; if(is_array($v)): echo " + <B>".$key."[".$k."]</B> - array()<BR>\n"; if((count($v)!=count($GLOBALS)) OR ($k!="GLOBALS")): echo_array_self($v,$key."['".$k."']",$x=$l+1); else: echo "Skipped - \$GLOBALS<BR>\n"; endif; else: echo " - ".$key."[".$k."]="; if(is_string($v)): echo "'$v'<BR>\n"; else: echo $v."<BR>\n"; endif; endif; } } /* include_once("functions/echo_array.php"); echo_array($GLOBALS,"GLOBALS"); */ echo_array($GLOBALS,"GLOBALS"); ?> - - (There are BR Tags before any New line chars. In preview it seems to make problem)

« previous php.notes (#22403) next »