I'm trying to convert my json object into array. I've saw many questions on SO but that didn't help me.
My PHP Code :
$arr = Array ( [1] => 10 [5] => 20 ) //array key is random
I want to assign above array to jQuery variable.
Jquery Code :
var obj = '<?php echo json_encode($arr)?>';
when i print obj it gives me {"1":"10","5":"20"}. i want result in array like [1:10,5:20].
And after that i want to access array values by its key (e.g. obj[1] or obj[5])
Ignore my syntax error.
Thanks.