PHP:
$arr[0] = 'A';
$arr['C'] = 'C';
$arr[10] = 'B';
echo json_encode($arr);
JQuery:
$.each(result, function(i, item) {
console.log(i + " => " + item);
});
Desired Output:
0 => A
C => C
10 => B
Instead I Get:
0 => A
10 => B
C => C
how can i prevent it to re-order my array without modifying the PHP code or restructuring the array?
Edit:
when ajax is called in response headers using firebug it seems to be in correct order:
"0":"A","C":"C","10":"B"
however when I do console.log inside $.each loop its re-ordered
for (var i=0; i<arr.length; i++)
loop – Bergi Apr 22 at 18:54