Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

[PHP3] automating variables From: Alexander BATKO (abatko <email protected>)
Date: 01/18/99

everyone knows that variables
take on the form
$VARIABLE

let's say i have many variables
of nearly the same name,
differentiated by appending a number.

for instance:
$VARIABLE_1
$VARIABLE_2
$VARIABLE_3
$VARIABLE_4
$VARIABLE_5
...
$VARIABLE_n

you get the point.

now, if i want to refer
to these variables
in a redundant way,
i'd like to make a
FOR function to run
through them.

what i'd like to do
is something along
the lines of:
for (i=0; i<100; i++)
  echo " $VARIABLE_$i ";

instead of doing:
echo " $VARIABLE_$1 ";
echo " $VARIABLE_$2 ";
echo " $VARIABLE_$3 ";
echo " $VARIABLE_$4 ";
echo " $VARIABLE_$5 ";
...
echo " $VARIABLE_$n ";

except you can see the
PROBLEM with this idea.

the $i is taken to be
a part of the variable
following the first $ symbol.

maybe there is some sort
of precedence that I could
impose???: ${VARIABLE_{$i}}
or $VARIABLE_{$i}

IS ANYONE ABLE TO
RESOLVE THIS ?

help will be much appreciated.

thanks in advance.

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3
List administrator:  zeev-list-admin <email protected>