| Posted by Chung Leong on 10/30/06 04:00 
hygum wrote:> is there a function, that can echo/print the name of an array, so when
 > i dump the array, it also says the name? For instance:
 >
 > echo array_name($myarray);
 >
 > outputs:
 > myarray
 
 This question pops up every now and then. The answer is you can use
 debug_backtrace() to get the source file and line number of the calling
 function, from which you can then extract the variable name with
 regexp. Not a foolproof technique and should only for debugging
 purpose.
 
 Do a search for debug_backtrace in this group and you should find a
 working  example I posted a few years ago.
 [Back to original message] |