I have a simple php array, something like $arr = ('volvo','mazda','bmw'..) How can I create js variables that all have the name based on the elements in the PHP array?
(I am asking for a method that would give me equivalant to hard coding this as
var volvo_js=0;
var mazda_js=0;
var bmv_js=0;
.. )
This naive attempt did not work:
var arr =<?php echo json_encode($arr);?>;
$.each(arr, function( index, value ){
var $(value+"_js")=0;
});