Re: Using Variable Variables from form values inside a function
| From: | Ron Dyck | Date: | Mon, 18 Feb 2002 13:55:24 +0000 |
| Subject: | Re: Using Variable Variables from form values inside a function | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85185@lists.php.net to get a copy of this message | ||
> > but, this doesn't:
> >
> > function myFunction() {
> > foreach($_POST as $key=>$value) {
> >
> > if (empty($$key)) {
> > print "empty value $key<br>";
> > }
> >
> > }
> > }
>
> Since php variable scope is local unless you define it global, that won't
> work that way. You might try (just guessing here):
> function myFunction() {
> foreach($_POST as $key=>$value) {
> global $$key;
> if (empty($$key)) {
> print "empty value $key<br>";
> }
> }
> }
That did it.
I assumed that since $_POST was global, the key/value pair would be. Guess
not :-|
Thanks!
ron