I am trying to convert a string into a variable. I know that this question has been already asked, but I can't get it to work. I need help. I have a few variables that I get through POST like this:
$name = $_POST['name'];
$prename = $_POST['prename'];
$array_var = array("name","prename");
$array_var_count = count($array_var);
for($t=0;$t<$array_var_count;$t++){
$var="$".$array_var[$t];
//echo("<script>alert('".$var."');</script>");
}
Now $var should get the value of :first:(name) and second of:(prename) because $var==("$".$array_var[$t])=> $var=$name;.
This means it should take the value of $name = $_POST['name'];.
Yet it doesn't. This is why I think I have to convert it into a variable. I'm not quite sure. I'm new in php. And I also want to check if $var is not empty, like this:
for($t=0;$t<$array_var_count;$t++){
$var="$".$array_var[$t];
..............................
if(!empty($var)){
..............................
}
}