>Yes it is, you must tell the function to treat the relevant variables as
>globals though, here is a way of doing it:
>function Foo(){
> $theArray = array('var1'=>'testing', 'var2'=>'testing2');
> foreach($theArray as $varname=>$value){
> global $$varname;
> }
> extract($theArray);
>}
>
>Foo();
>echo "$var1<BR />$var2";
>
>The above code outputs "testing<BR />testing2".
Pretty sneaky. But at this point, why bother with the extract() at all?
wouldn't this do the same thing:
function Foo(){
$theArray = array('var1'=>'testing', 'var2'=>'testing2');
foreach($theArray as $varname=>$value){
$GLOBALS[$varname] = $value;
}
}
Which is what I am already doing...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php