Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables

Status
Not open for further replies.

stacybk

Programmer
Joined
Oct 22, 2003
Messages
15
Location
US
I have a loop. In each iteration of the loop I need to use a different array. At the beginning of the loop I set the array name to a variable. For instance, if $x is the loop counter, I write

$myarray = "thearray$x";

I'm not sure how to reference it later. For instance, if I use
print_r ($myarray) i get thearray1.

Any ideas?
 
Why not use a multi-dimensional array?

You could just manipulate
Code:
$myarray
in the loop, and at the end set {code]${"thearray$x"} = $myarray[/code].

//Daniel
 
I can't use the multidimensional array, because of the way the data is being passed to me.

But, thanks.
 
I found a work around. If anyone knows the original answer, though, I am still curious.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top