Re: How get the name of the array variable?

From: Date: Fri, 15 Feb 2002 13:19:41 +0000
Subject: Re: How get the name of the array variable?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-84893@lists.php.net to get a copy of this message
> This doesn't solve the strval problem, :((( it's the only problem I have > but in my debug output I wasn't so > interested in the array's name, as in the meaning/status of the data it > contained. Here is an equivalent approach (- the idea of nesting the two > functions was the subject of a conversation with Torben here, a few days > back): > > Please feel free to translate it into Polish. How did You know it was Polish? :) > I haven't tried to time/test, but I figured that the array_walk() would be > more efficient than writing an (interpreted) PHP loop to run through the > entire array/list, even with the function call. Efficient is not the main problem when U debuging scripts IMHO. I found that on php.net in doc. function db($call,$cname) { // call: the variable you want to print_r // cname: the label for your debugging output if (DEBUG) { global $SCRIPT_NAME; echo "<pre><font size=2>$cname in $SCRIPT_NAME"; if (!is_array($call)) { $call=htmlspecialchars($call); } print_r($call); if ( is_array($call)) { reset($call); } echo "</font></pre>------------------------------------------"; } // end function db() ====================== } Very nice IMO, but still not solve the value name problem. BTW it's third solution that I see and every one of them have "label for your debugging output" given as parameter. But I'm very lezy and I prefer to write down db($my_var) then db($my_var,"this is my_var"), I doing lot's of debugin. Regards, TG

« previous php.general (#84893) next »