
rmh_va
Novice
Aug 17, 2011, 10:43 AM
Post #20 of 32
(4210 views)
|
|
Re: [FishMonger] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop?
[In reply to]
|
Can't Post
|
|
for at least the 10th time, I do not have access to the code that creates these variables, it's done elsewhere, and I don't have auth. to change it... Of course an array would be smarter/better, but it's not available... stop suggesting this, if you don't know how to do the interpolaiton, kindly leave this to someone that does... I orignially asked if anyone knows how to fix my interpolation problem... here's the code... I have 8 variables... I would like to reference them in a loop without hard-coding the names... $sub1 = 'var1name/var1text'; $sub2 = 'var2name/var2text'; $sub3 = 'var3name/var3text'; $sub4 = 'var4name/var1text'; $sub5 = 'var5name/var1text'; $sub6 = 'var6name/var1text'; $sub7 = 'var7name/var7text'; $sub8 = 'var8name/var8text'; print '<table>'; while ($i < 9) { $temp = "$sub.$i"; @xr = split("/",$temp); print '<tr><td>',$xr[0],'</td><td>',$xr[1],''; $i++; } print '</table>'; I want to fix this statement: $temp = "$sub.$i"; I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck... can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above... thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment... thanks...
|