Passing numerically indexed PHP array to javascript

potterhead1

New Member
I've got a PHP array in this format:\[code\] $js_data_array[] = array('href' =>$matches[1][0], //this is an image url 'title' =>'Lorem ipsum dolor sit amet, consectetur adipiscing elit', );\[/code\]And I need to get it into this format in javascript\[code\] [{'href' : 'http://farm5.static.flickr.com/4005/4213562882_851e92f326.jpg','title' : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'},{'href' : 'http://farm5.static.flickr.com/4005/4213562882_851e92f326.jpg','title' : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'}]\[/code\]I'm using wp_localise_script() in wordpress to pass the data which doesn't seem to accept a json encoded array.If I pass the array as is, I get a numerically indexed array with duplicate values of 'Array'So, the question is, how can I pass the data as an array but without the numeric indexes? I can't have duplicate keys in a php array AFAIK.
 
Back
Top