Re: array to var - with different name

From: Date: Fri, 21 Jan 2011 18:40:12 +0000
Subject: Re: array to var - with different name
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-310961@lists.php.net to get a copy of this message
Paul M Foster wrote: [snip]
Shawn, I don't know if I have a good reason, other than I rather like working with string vars instead of array vars from $_REQUEST for (sticky forms and conditionals). I can check/verify them as well in the process.
You should probably get used to dealing with the array variables. However, you can also look at the extract() function. It won't do exactly what you want, but it will pull the array keys/values into the current symbol table. Use with caution (note the second parameter to the function). Paul
Well, It occurs to me that you can't code in PHP without getting use to dealing with arrays. ;-) I just much rather like typing: <input name="f_email" value="<?PHP if (isset($t_email)) { print htmlspecialchars($t_email);} ?>" /> Instead of: <input name="f_email" value="<?PHP if (isset($_GET['f_email'])) { print htmlspecialchars($_GET['f_email']);} ?>" /> or if ($t_ok) { } instead of: if ($_GET['f_ok']) { } Save's a lot of typing time as far as I can tell. Donovan -- D Brooke

« previous php.general (#310961) next »