Re[2]: [PHP] Get "nice" variables from POST
| From: | Richard Davey | Date: | Thu, 11 Mar 2004 15:42:49 +0000 |
| Subject: | Re[2]: [PHP] Get "nice" variables from POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180173@lists.php.net to get a copy of this message | ||
Hello Ryan,
Thursday, March 11, 2004, 3:29:32 PM, you wrote:
>> Does this look nicer?
>>
>> $fields = array('username', 'password', ...);
>> foreach($fields as $key) $$key = $_POST[$key];
RA> A bit confused...whats the meaning of the double $ for "key"...or is that a
RA> typo?
It creates a variable variable :)
A variable variable takes the value of a variable and treats that as the name of a variable.
See Chapter 7 (Variables) of the PHP manual.
--
Best regards,
Richard Davey
http://www.phpcommunity.org/wiki/296.html