English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$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 < 100; $i++) {
$tempvar = "a".$i

}
echo " $i\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

2006-11-16 00:19:16 · 3 answers · asked by f1avor_f1av 3 in Computers & Internet Programming & Design

3 answers

arrays !!!! not simple variables!

2006-11-16 05:03:34 · answer #1 · answered by jake cigar™ is retired 7 · 0 0

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.

2006-11-16 08:29:46 · answer #2 · answered by Anonymous · 0 1

Try making an array instead of 100 variables. Something like this:

$a[]='blue';
$a[]='red';
$a[]='black';

for ($i=0; $i < count($a); $i++)
{
echo '' .$a[$i] . '';
}

2006-11-16 10:42:45 · answer #3 · answered by Farnsworth 3 · 0 1

fedest.com, questions and answers