Posted by Sjoerd on 04/13/06 14:09
Garry Jones wrote:
> This by recycling the code with $personX in and changing the value of x and
> running the code ten times. Probably in some kind of do while loop (fairly
> new to php, but I have been using Excel VB for years and am familiar with
> the syntax and effectiveness of Do While Loops).
You probably want to use arrays, which are variables which can contain
multiple values.
$personage[1] = 'John';
$personage[2] = 'Gerry';
You can use $personage[1] as you would use any other variable. You can
loop through this array with:
foreach ($personage as $person) {
echo $person;
}
This would print "JohnGerry".
See
http://nl2.php.net/manual/en/language.types.array.php
for more information about arrays.
It is possible in PHP to have variable variables (e.g. specify the name
of the variable in another variable), but it is almost never what you
want.
Navigation:
[Reply to this message]
|