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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.