I’m using this code in a for loop to push items to an array but it doesn’t add to the array, just overwrites it each time I think:
drupal_add_js(array('THINGS' => array('ONE' => array('VAR' => $var_one), 'TWO' => array('VAR' => $var_two), 'THREE' => array( 'VAR' => $var_three))), 'setting');
So this is what I end up with:
"THINGS":{"ONE":{"VAR":"blah blah blah"},"TWO":{"VAR":"blah blah blah two"},"THREE":{"VAR":"blah blah blah three"}}
When what I want is this:
"THINGS":{"ONE":{"VAR":"blah blah blah", "VAR":"blah blah blah one"},"TWO":{"VAR":"blah blah blah two","VAR":"blah blah blah two two"},"THREE":{"VAR":"blah blah blah three","VAR":"blah blah blah three three"}}
So I guess my question is, how do I print objects within objects using this method, or would it be easier to just push the variables with javascript within a script tag?
Any ideas? Am I doing this right?