I have this PHP code –
<?php
for($i=1; $i<=1000; $i++) {
$array=array();
$array[$i]=54*$i;
$arr=array($array[$i].",");
foreach ($arr as $value) {
echo $value;
}
}
?>
I tried with:
var i;
for(i=1;i<=1000;i++) {
var array = new Array();
array[i] = 54*i;
var arr = new Array();
arr.push(array[i]+",");
}
alert(arr)
But it doesn’t work.
Where’s the mistake?
Wild stab.. because the PHP code while it may produce the expected output, is actually ‘wrong’ (wrong on the basis that you may expect the array to hold all those values, and it doesn’t).
so here’s the php (fixed).
and here’s a JS alternative