note 27650 modified in function.each by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Sat, 14 Dec 2002 00:24:14 +0000 |
| Subject: | note 27650 modified in function.each by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40892@lists.php.net to get a copy of this message | ||
[Editor's note: A much simpler one-line solution would be to either a) turn register_globals on
in php.ini, or b) use extract($_POST)]
This is almost stating the obvious, but especially for new users or those migrating to the newer PHP
versions where register_globals is defaulted to OFF now. Simply put this at the top of all pages
that require form data input and you won't have to go recode everything by prefixing the $_POST
in front of it.
reset ($_POST);
while (list ($key, $val) = each ($_POST)) {
//echo "$key => $val<br>\n";
$$key = $val;
}
basically it's mapping all the $_POST keys to a variable of their same name and then assigning
the $_POST value to the new variable we just created.
--was--
This is almost stating the obvious, but especially for new users or those migrating to the newer PHP
versions where register_globals is defaulted to OFF now. Simply put this at the top of all pages
that require form data input and you won't have to go recode everything by prefixing the $_POST
in front of it.
reset ($_POST);
while (list ($key, $val) = each ($_POST)) {
//echo "$key => $val<br>\n";
$$key = $val;
}
basically it's mapping all the $_POST keys to a variable of their same name and then assigning
the $_POST value to the new variable we just created.
http://www.php.net/manual/en/function.each.php