Re: Using Variable Variables from form values inside a function

From: Date: Mon, 18 Feb 2002 13:47:18 +0000
Subject: Re: Using Variable Variables from form values inside a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85184@lists.php.net to get a copy of this message
----- Original Message ----- From: "Ron Dyck" <adam@webbtech.net> > 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>"; } } }

« previous php.general (#85184) next »