generating variable names
| From: | Kevin Heflin | Date: | Fri, 06 Sep 2002 18:37:51 +0000 |
| Subject: | generating variable names | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-115535@lists.php.net to get a copy of this message | ||
Hoping someone can help me with this. Below I have an example of what I'm trying to accomplish.
Bottom line.. I need to print out $variable3[0] and $variable4[0]
and my problem is that I'm trying to generate the variable name. I can get this to work with $variable1 and $variable2 which are not arrays, however that doesn't help me much.
Any suggestions would be appreciated.
Kevin
<?
$variable1="one";
$variable2="two";
$variable3[0]="three";
$variable4[0]="four";
$j=1;
while($j<5){
print("${variable.$j} <BR>");
$j++;
}
$j=1;
while($j<5){
$k="\$variable".$j."[0]";
print("$k <BR>");
print("${variable.$k} <BR>");
$j++;
}
?>