How exactly do you use json_decode to pass a javascript array to php?
- by Adam
This is how I got my php array to javascript
echo 'var daysofweek = '.json_encode($daysofweek).';';
Now I am aware that json_decode can do the opposite, however the problem is I don't know the syntax to do so.
I tried:
<script>
var array_days = new Array();
array_days[] = "psdfo";
array_days[] = "bsdf";
<?php
$array_days = json_decode(?>array_days<?php);?>
</script>
yes im clueless.
I forgot to mention that I want to send an array through post, having all my information regarding all the form values dynamically created by javascript. Otherwise, I wouldn't know which name="" to look for as it will be decided by the user. Unless someone else has an alternative solution...