Re: looping variables from a file

From: Date: Wed, 24 Mar 2004 18:51:30 +0000
Subject: Re: looping variables from a file
Groups: php.general 
Request: Send a blank email to php-general+get-181389@lists.php.net to get a copy of this message
Hey John, > $array1 = get_defined_vars(); > include('yourfile.php'); > $array2 = get_defined_vars(); > $newvars = array_diff($array2,$array1); > foreach($newvars as $name => $value) > { echo "$name = <font color=\"green\">$value</font><br > />\n"; } Cool, thanks, will try it out. > If there are multi-dimensional arrays, then > you'll need a recursive > function. Have fun! Nope, I don't use multi-dimensional arrays unless absolutely no other way.. they get too complicated and gives me a headache when I try to understand them if I come back to the project after a long time Definitely not my idea of fun. > This is all assuming the user comments are correct and variables from > include()'d > files are captured by get_defined_vars(). Yep, will check that out, but it should..will write back to the list if it does'nt. Thanks again. Cheers, -Ryan P.S I got the other script working where I force the download of a php file while creating the file dynimacally and not having the file on the server, works great. Thanks for that idea too. (Incase you dont remember, the subject of that was "outputting php file")

« previous php.general (#181389) next »