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?
Constructing Arrays with loops
Moderator: General Moderators
-
rhythmicimaging
- Forum Newbie
- Posts: 1
- Joined: Fri Oct 25, 2002 7:09 am
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
Basic Functions
You have to check basic things like for, while, foreach
hope it helps
PS: check array in the manual
Code: Select all
<?php
for ($i; $i<=5; i++)
{
$my_arrayї$i] = "a" . $i;
}
?>PS: check array in the manual