-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey John,
Actually, you don't seem to far off. You can use a string as a variable name by enclosing the string in ${ }. i.e: ${"foo"} You should be able to write your loop as something like: foreach($item as $value) { // do some stuff foreach(${"prefix${value}suffix"} as $v) { // do some stuff } } All of the normal string and variable rules apply, so you can do things like: echo ${ "some" . $bar ."text"}; ${"prefix${baz}suffix"} = 100000; ${md5($quux)) = $quux; There is also the added behavior (benefit?) of being able to use odd values for variable names: echo ${" \n\t"} = "Holy Whitespace, Batman!"; HTH! - --zak On September 10, 2002 17:26, John Kelly wrote: > Hi, I have 1 primary array called $item containing 20 values each of whose > value is part of the name of 20 other arrays containing various number of > values. How can I cycle through the primary $item array using a foreach > and within that do a for on each of the 20 secondary arrays dynamically > inserting each of the 20 secondary array names based on the value of the > current primary $item array. Something like the following which obviously > does not work. > > <?php > > foreach($item as $value) { > // do some stuff > for($i=0; $i<count($"beginning_of_array_name_always_the_same" . $value . > "end_of_array_name_always_the_same"); $i++) { > // do some stuff [chop] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9frG7b6QONwsK8bIRAlehAJ9ivM6lWm3mu68Gy43vKKPvmZo+CgCfdBdf 5IikMTwLaBwKPvoFDz4CfD0= =CjQD -----END PGP SIGNATURE----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php