Forum Moderators: coopster
$i=0;
while ($i < $num) {
etc...
but how do I get a variable to take the name of $i, for example $variable$i. I also then want to create a variable which has all the variables created in this loop, for example:
$overall = "$variable0$variable1$variable2" etc....
How is this done?
Any help appreciated
Chris
it does get confusing though so here is an example
$num = 10;
$i=0;
while ($i < $num) {
${'varname' . $i} = 'somevalue';
$i++;
$totalvar .= ${'varname' . $i};
}
this is a pretty redundant example
>> I also then want to create a variable which has all the variables created in this loop
you could really just use an array then
$num = 10;
$i=0;
while ($i < $num) {
$varname[$i] = 'somevalue';
$i++;
}
echo '<pre>';
print_r($varname);
echo '</pre>';
not sure exactly what you are trying to do so neither of those may be the best idea.
Moreover see coop wrote about using arrays. Arrays are better than a bunch of variables, because you can do lots of things on them.
Best regards
Michal Cibor