473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

$$vars_var

TheServant
1,168 Expert 1GB
Hi guys, I am trying to make a variable variable array but it won't work:
Expand|Select|Wrap|Line Numbers
  1.     function test_vars( $prefix, $test ) {
  2.         $array_name = $prefix . "_test";
  3.         $$array_name['var1'] = 10 * 1.2;
  4.         print_r($$array_name);
  5.         print_r($u_test);
  6.         echo($$array_name['var1']);
  7.         echo($u_test['var1']);
  8.     }
  9.     race_vars(u,human);
If I run this function, it's only the echo($$array_name['var1']); that is working? Can anyone see where I am going wrong?
Mar 10 '09 #1
4 1073
Dormilich
8,658 Expert Mod 8TB
do you mean
Expand|Select|Wrap|Line Numbers
  1. ${$array_name[$key]}
or
Expand|Select|Wrap|Line Numbers
  1. ${$array_name}[$key]
?
Mar 10 '09 #2
TheServant
1,168 Expert 1GB
Awesome, that's what I needed! Thanks.
Mar 10 '09 #3
Dormilich
8,658 Expert Mod 8TB
*evil_grin*

btw. happy 600 posts!
Mar 10 '09 #4
TheServant
1,168 Expert 1GB
w00t!!! Thanks, didn't even notice!
Mar 10 '09 #5

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.