Re: renaming form posted variable names
| From: | David Minor | Date: | Tue, 03 Apr 2001 05:24:28 +0000 |
| Subject: | Re: renaming form posted variable names | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-46761@lists.php.net to get a copy of this message | ||
Richard Lynch writes:
> function do_each($passed_array) {
>
> global ${$tmp_var_name};
Move this:
>
> if (substr($passed_array[0],-5) == "_post") {
> $tmp_var_name = substr($passed_array[0],0,-5);
> ${$tmp_var_name} = $passed_array[1];
down here.
> return(${$tmp_var_name});
> }
> }
Yes, I did that. I must've been going in a different direction when I made
it two functions.
Problem reamins: Before exiting the function, I can print the true variable
name/value pair. As soon as I exit the function, the same print statement
returns "". Is it possible to make the variable variable global? Here's
what I know have:
function conv_vars($input) {
global ${$tmp_var_name};
if (IsSet($input)) {
while ($each_array = each($input)) {
if (is_array($each_array[1])) {
conv_vars($each_array[1]);
}
else {
if (substr($each_array[0],-5) == "_post") {
$tmp_var_name = substr($each_array[0],0,-5);
${$tmp_var_name} = $each_array[1];
}
}
}
}
}