We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,886 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

php associate array to javascript

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

2
Contributors
3
Replies
2 Hours
Discussion Span
2 Months Ago
Last Updated
11
Views
Question
Answered
dinhunzvi
Junior Poster in Training
74 posts since Jul 2010
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 0

php json_encode code be a help

code739
Posting Whiz in Training
208 posts since May 2012
Reputation Points: 17
Solved Threads: 28
Skill Endorsements: 5

have no idea what json is.

dinhunzvi
Junior Poster in Training
74 posts since Jul 2010
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 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;?>)
code739
Posting Whiz in Training
208 posts since May 2012
Reputation Points: 17
Solved Threads: 28
Skill Endorsements: 5
Question Answered as of 2 Months Ago by code739

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0654 seconds using 2.68MB