Forum Moderators: coopster
$a = 'apple';
$num = '5';
${$a . $num} = array('one','two','three');
echo '<pre>';
print_r($apple5);
echo '<pre>';
make any sense at all?
I use it for all sorts of things.
Mostly when I don't know how many of something there will be so I use a counter to create the vars. ending up with var1, var2, var3, etc. I can then loop through, or just use, them later no matter how many there end up being.
$getDose=0;
$a = 'comp';
$$a=$getDose; //This create variable $comp=0.
$a.${$a} = array(); //This create array named comp0
$a.${$a}[0]="sherif"; //This put "sherif" in index[0]
hope what i am saying is right... so the problem now is i cant display what is at index[0].
i tried:
echo"$a.${$a}[0]";
it gave:
comp.Array[0]
so what should i do?
thanks in advance
$getDose=0;
$a = 'comp';
${$a . $getDose}
this is constructing the variable name, it reads something like this
the variable who's name is the value of the variable a concatenated with the value of the variable getDose.
so..
${$a . $getDose} = array();
${$a . $getDose}[0] = 'sherif';
echo ${$a . $getDose}[0];
any better?