I have a problem and do not know what the problem is. I have a javascript variable in my html. which is:
var people = '{"names": ["Matthew", "Lucas", "Todd", "Roxie", "Kyle", "Ken", "Gideon"], "surnames": ["Patel", "Lee", "Ingram", "Richter", "Katayanagi", "Katayanagi", "Graves"]}';
I parse the variable on one function in my script and use it. Everything works fine.
var mydata = JSON.parse(people);
But then I need to send the data to a php file, I send it by wrtting the data to a hidden input.
var strObject = JSON.stringify(mydata);
var replaced = strObject.replace(/\//g, '');
oFormObject = document.forms['theForm'];
oFormObject.elements["jsonData"].value = replaced;
After which I try to encode it in my decode.php using:
$obj = $_POST['jsonData'];
json_decode($obj);
$s = stripslashes($obj);
var_dump($s);
But when I do a var_dump($s) I get this output:
string(147) "{"names":["Matthew","Lucas","Todd","Roxie","Kyle","Ken","Gideon"],"surnames":["Patel","Lee","Ingram","Richter","Katayanagi","Katayanagi","Graves"]}"
Thus, I cannot output the contents in $s.Any suggestions.Please let me know if you need more information. BTW, its a homework assignment and I am stuck with the last section.