$a1 = "blue"
$a2 = "red"
$a3 = "black
$-- = "--"
$a100 = "purple"
So i have 100 variables defined
If i want to display alll of the variables in a table, but each one on a separate row, how could i look it, i dont have to type in al 100 rows
for ($i = 1; $i %26lt; 100; $i++) {
$tempvar = "a".$i
}
echo " %26lt;td%26gt;$i%26lt;/td%26gt;\n";
i cant figure out how to get the value of of the a's(a1,a2,a3, etc.) to incorporate themselves into the loop. Please help, ty
Javascript or PHP or C++ Programmers?
arrays !!!! not simple variables!
Reply:Try making an array instead of 100 variables. Something like this:
$a[]='blue';
$a[]='red';
$a[]='black';
for ($i=0; $i %26lt; count($a); $i++)
{
echo '%26lt;td%26gt;' .$a[$i] . '%26lt;/td%26gt;';
}
Reply:Instead of 100 variables, use one array with 100 elements. Then you can reference a[0]..a[99]. Check your manuals / reference material or search the net on how to declare and use arrays.
Rawlyn.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment