Q:

Passing a PHP array via Javascript to another PHP script

I may be going about this the hard way, as I modeled my code after an older article: populating triple dropdown list but I have found I don't need to query the database, because all the information is already neatly stored for me in a PHP array used earlier in the script.
I have a PHP array already created ($events):
<?php foreach($events as $event) {                    

Now I have to pass the events array to another file for processing:
<select name="search_month" onChange="getMonth('filter-leaderboard.php?month='+this.value)">

I'm just not sure how to pass it via Javascript.
How do I go about doing that?
Thanks!

A:

Looking at your question, it appears you're trying to get the month using AJAX?
If so, it'd probably be better to post the array as the body rather than doing a get request.
You can use the json_encode function (http://au2.php.net/json_encode) to convert the array into a JSON object so you can work with it in JavaScript.

