Creating 'for loop' of variables containing some value, in javascript

Viewed 59

How can I create a for loop of a different variables in javascript that hold different values.

This a part of my code:-

<?php 
$phparray = array();
array.push($phparray, "//some value");
?>
<script type = "text/javascript>
var a = "<?php echo $phparray[0] ?>";
var b = "<?php echo $phparray[1]?>";
</script>

In this code, want a for loop instead of defining each element separately. Also if possible, I want a variable which will hold values of both var a and var b.

2 Answers
Related