Hello
I was wondering how I could use a for loop to say assign Item1, Item2, Item3, ... ItemN.
Instead of doing:
$item1=1; $item2=2; $item3=3; ... $itemN=N;
Very simple example of what I am trying to do but...answering this will solve all of my other issues...and greatly simplify my code.
Thanks in advance.
One way would be to use an array:
$item = array(); for ($i = 1; $i <= $n; $i++) { $item[$i] = $i; }
Another way would be to use variable variables:
for ($i = 1; $i <= $n; $i++) { ${'item' . $i} = $i; }
I would recommend using the array method.
I knew it was something simple. Thank you very much laserlight.
This is a great forum, I will be here a lot.