In the following code I simple feed the values of the form
$t = $_GET['type'];
$p = $_GET['product'];
$b = $_GET['brand'];
$c = $_GET['category'];
$attribute = getattributes($p,$b,$c);
$count = count($attribute);
$i=0;
The variable $attribute has
Array([0]=>size [1]=>weight)
Now using the above array i want to generate the following lines
$size = $_GET['size'];
$weight = $_GET['weight'];
I don't want to assign manually just like the above but create the two lines using loops.
Something like
$i=0;
while($i < $count)
{
'$'.$attribute[$i] = '$_GET['.$attribute[$i].']'; //edited part
}
I don't know if this will work, could somebody provide a simple piece of code to achieve the same?
Solution Code:
Awlad Liton: Thank for your answer. There is a minor change in your code which gave the desired output (value form the form)
foreach($attribute as $k => $v){
$$v = $_GET[$v];
}