Accessing variables, with a for-loop

From: Date: Mon, 19 Jun 2000 12:30:22 +0000
Subject: Accessing variables, with a for-loop
Groups: php.general 
Request: Send a blank email to php-general+get-2189@lists.php.net to get a copy of this message
I have gotten some old code for which I have to make some changes to. And in the code you have places where the person haven't used arrays but have code like this : $variable1 = $variable2 = $variable3 = $variable4 = $variable5 = Now I wonder if it could be possible to access these variables this way (or in some other easy way?) for ($i = 0; i < max; i++) { $variable$i // -Hmmmm Can I do this in some way? :) } Had it been an array I could just have written $variable[i]; but since the codes have several places with the kind of "stupid" code I mentioned earlier, it would make things much more easy for me if I could access them in a for or while loop. I haven't used php much, but I'm trying to learn it now.... :) Erlend Stromsvik

« previous php.general (#2189) next »