If I'm thinking right, this should work...can someone help me
understand why it's not.
//$loop = 1
$test = "num$loop"; //test should now equal "num1"
$ttest = $$test; //ttest should now reference $num1
echo $test; //this echo DOES show "num1"
echo ${$ttest}; //this echo shows nothing (blank)
echo $num1; //this echo shows the contents of $num1
correctly.
What I'm doing is this: From a previous form I have outputted a bunch
of variables: $num1, $num2, $num3...$name1, $name2, $name3.
In my script I want to put in a loop a dynamic reference to each of
these...the step the loop is in will = the last digit in the variable.
What am I missing here? Can someone help?
Thanks,
Chris
understand why it's not.
//$loop = 1
$test = "num$loop"; //test should now equal "num1"
$ttest = $$test; //ttest should now reference $num1
echo $test; //this echo DOES show "num1"
echo ${$ttest}; //this echo shows nothing (blank)
echo $num1; //this echo shows the contents of $num1
correctly.
What I'm doing is this: From a previous form I have outputted a bunch
of variables: $num1, $num2, $num3...$name1, $name2, $name3.
In my script I want to put in a loop a dynamic reference to each of
these...the step the loop is in will = the last digit in the variable.
What am I missing here? Can someone help?
Thanks,
Chris
Comment