views:

22

answers:

1

Hello everyone,

I have a SESSION that looks like this:

array(1) { [1]=>  array(11) { ["aantal"]=>  int(1) ["id"]=>  string(2) "29" ["filmtitel"]=>  string(16) "2_fast_2_furious" ["film_id"]=>  string(1) "1" ["zaal_id"]=>  string(1) "1" ["zaaltitel"]=>  string(6) "zaal 1" ["tijdstip"]=>  string(8) "17:30:00" ["stoeltjes"]=>  array(3) { [0]=>  string(2) "19" [1]=>  string(2) "20" [2]=>  string(2) "21" } ["dag"]=>  string(8) "woensdag" ["verwijder"]=>  int(1) ["vertoningId"]=>  string(2) "31" } } 

so there is an array and within that array is another array called "stoeltjes" with 3 items.

What i would like to know is how i can direct the content of "stoeltjes" to jquery so i can assign it to a flashvar and send it to as3.

Anyone who can help?

A: 

Take a look at json_encode if you have php 5.2 or higher. The resulting variable from that function can be set as a javascript variable.

I think it's something like this:

echo "
<script>
var stoeltjes = eval(".json_encode($_SESSION['stoeltjes']).");
</script>
";

Now 'stoeltjes' is a array with the same values but then in javascript.

Leon
i think this should work but the problem is that my jquery is in a seperate file so i dont think this would be recognised. Or am i wrong?I definitly get an error saying the syntax is wrong
vincent
I'm sorry, i can't try it out right now. But try it without the eval statement: var stoeltjes = ".json_encode($_SESSION['stoeltjes']).";. But this is the way to do it, seperate files shouldn't matter.
Leon