Page 1 of 1

Constructing Arrays with loops

Posted: Fri Oct 25, 2002 7:09 am
by rhythmicimaging
Hello

i'm fairly new to PHP. and i've got my head round using an array for the creation of a simple table of chapers.

While working on it i wondered if it would be possible to create an array with a loop, so the contents could be say, a1, a2, a3, a4, a5.

so what would happen is a loop would increment a variable ($i) by one every time till the condition was met. then each bit of data in the variable would be set from:-
a + $i

If this is possible, is there a more common name for the technique etc and more importantly is it possible?

Basic Functions

Posted: Fri Oct 25, 2002 7:17 am
by AVATAr
You have to check basic things like for, while, foreach

Code: Select all

<?php
for ($i; $i<=5; i++)
   {
    $my_arrayї$i] = "a" . $i; 

   }
?>
hope it helps

PS: check array in the manual