How do you use value of variable as variable name?

by 4 replies
5
I have these lines:

But it only alerts something like:

Please help, thank you.
#programming #variable
  • Can you post what you're goal is? Maybe knowing that can point us in the right direction.
  • Banned
    [DELETED]
    • [2] replies
    • It's much better to do something like this:

      Code:
      var ddArray=['holidayTypes','groupType','group_status'];
      for(var x in ddArray) window[ddArray[x]] = 0;
    • Except that the code given isn't PHP it is javascript and your example will fail since $12 isn't a valid variable name.
      • [ 1 ] Thanks

Next Topics on Trending Feed