Jump to content

Using a variable to "call" the value of another variable


wisemaar

Recommended Posts

I am sure somebody must have had this problem before!!!
Basically I have retrieved information from a database and the results (which are names) are stored in variables named Player_1, through to Player_11.
I want to use a "counter" to loop through each record and display it..
The code I have come up with to do this is below:

$Players = 11;  (This could be any number between 7 &11)
$i=1;  // Set up a counter.
while ($i<=$Players) {
$a = '$Player_'.$i; 
echo $a;
}

This works except that I it displays the value of $a, ie $Player_1, where as I want to display the value of the variable $Player_1

Any help would be much appreciated as I have been pulling my hair out with this, and I don'y have a lot left!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.