ok…in php how do i do this? given the following scenario:
// array of letters var $letters = array('a', 'b', 'c'); // loop through array and create empty arrays with names like $a, $b, $c foreach($letters as $letter) { var $$letter = array(); }
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your code was almost correct. You just need to remove ‘var’ on the 2nd and fifth lines.
This works correctly (as you described). I tested it.
More information on variable variables here.
As an aside, I would recommend against using eval() in your PHP.