Re: array to var - with different name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tommy Pham wrote:
[snip]
foreach ($_REQUEST as $key =>  $value) $$key = $value;

short-circuited one-liners :)

Regards,
Tommy


akk... wrong clicked before I had a chance to fix the code. anyway,

foreach ($_GET as $key =>  $value) if (substr($key, 0, 2) == 'f_')
${'t_'.substr($key, 2)} = $value;


Tommy, excellent.. I had just rewrote your first suggestion:

foreach ($a_formvars as $key => $value) ${str_replace('f_', 't_',$key)} = $value;

(which works)
but I like that you are only affecting the vars that *begin* with $match. I suppose the above would also work with $_REQUEST.



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.

Thanks to all that posted.. I always learn from the "skin the cat" game.

Donovan



--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux