1,105,384 Community Members

php associate array to javascript

Member Avatar
dinhunzvi
Junior Poster in Training
98 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

i have a php associate array and i want to convert it to a javascript array. how best do i do this

Member Avatar
code739
Posting Whiz in Training
213 posts since May 2012
Reputation Points: 17 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 6 [?]
 
0
 

php json_encode code be a help

Member Avatar
dinhunzvi
Junior Poster in Training
98 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

have no idea what json is.

Member Avatar
code739
Posting Whiz in Training
213 posts since May 2012
Reputation Points: 17 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 6 [?]
 
0
 

read this
http://www.w3schools.com/json/default.asp

then

use json_encode in your php like
$JSON = json_encode($your_array) then pass this in your javascript
example

javascript_function(<?php echo $JSON;?>)
Question Answered as of 1 Year Ago by code739
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: