A simple start will be, example array
<?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); ?> <script type="text/javascript"> var arr = <?php echo json_encode( $arr );?>; alert(obj['a']) <script>
Output: “1″
Another example given array:
<?php $arr = Array ( [136438349186fwjbr] => test3 [136444493417krous] => sports4 [136444501982ununp] => Sports3 [136444538415upydf] => Sports6 ) ; ?> <script type="text/javascript"> var subArray = <?php echo json_encode( $arr );?>; $.each(subArray, function (i, elem) { alert(i + ' is ' + elem); } ); </script>
Output: “136438349186fwjbr is test3″ etc….
What do you think?