Tomek, > I got the problem , I want make preety debug function that shows array keys > and values and name of the variable containing array: > Here it is: > > function show_arr($array) > //wyswietla wartosci z tablicy wraz z kluczami (przeznaczone do debugowania) > { > if(DABUG) > { > echo "<b>-------------------------------------------</b><br>"; > echo "Array contents<b>".strval($array)."</b><br>"; > while(list($k,$v)=each($array)) > { > echo "$k = $v<br>"; > } > echo "<b>-------------------------------------------</b>"; > } > } > > unfortunatly strval want work with arrays... > Any possible solution how to get name of the array variable?
This doesn't solve the strval problem, 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): Function ShowList( $title, $aList ) // Debug output routine to echo an array/list to the screen // requires a documentary name for the list as $title // requires the array to be listed as $aList // NB co-requisite FnShowListItem { echo "<br>Listing array=$title: n=" . count( $aList ); array_walk( $aList, "FnShowListItem" ); } Function FnShowListItem( $item, $key ) { echo "<br>$key=" . $item . "~"; } //end of function ShowList In the main routine make a call something like: if ( DEBUG ) ShowList( "Prefixed", $aURLs ); Please feel free to translate it into 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. Perhaps someone can confirm/refute that? Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php