PHP: $_POST vars
- Started
- Last post
- 7 Responses
- nRIK
hello, need some help,
how can i automatically convert all my $_POST vars so i can refer to them just through their $key?For example:
$myvar = $_POST['myvar']but in a foreach loop:
foreach($_POST as $k=> $v){
$k = $v
}but that doesnt seem to work :(
thanks in advance,
- nRIK0
i guess im trying to assign a dynamic name to a new variable
- webhead0
Just use:
import_request_variables("gpc");
Imports get, post, or cookie vars into local variable names.
Though you really should just use $_POST, it is much more secure.
- nRIK0
yea i had thought so too,
thanks for the tip
- Rickbass0
Might just be a code error in your first post too. Try:
foreach ($array as $key => $value ) {
$$key = $value;
}
- index_html0
yes you will need
$$key
and you can use $_REQUEST - that will give you POST and GET data in one array ; )
- funth0
this isn't the greatest plan in the world, but just so you know;
foreach($_POST as $key=>$var) {
${$key}=$var;
}
- nRIK0
ah how silly, a $$
makes perfect sense now :P
thank you , i will try it out