Php Pass Array To Javascript
I want an array in Javascript, structure like this $(function() { // prepare the data for (var i=0; i<50000; i++) { var d = (data[i] = {}
Solution 1:
ie, $data = array('item' => 'description', 'item2' => 'description2');
json_encode($data);
All you need
Solution 2:
Use json_encode() to encode the array.
Access PHP variable in JavaScript That example works with arrays, too.
Post a Comment for "Php Pass Array To Javascript"