> Wait until after the for loop has completed. > for ($i=0; $i< $num_results; $i++) { > $variable[$i]; > } > global $variable;
That's not going to work. The only thing that is doing is making an already global instance of $variable global within the function. What you want is this instead: $GLOBALS[$variable] = $variable; Chris