title: Decoding JSON Array of Objects in PHP, is it the back slashes?
body: <p>So I'm posting an array of objects in a JSON string using javascript to a PHP script and I'm having real problems decoding it in the php.</p>
  
  <p>My javascript is as follows:</p>
  
  <pre><code>$.ajax({
      type: 'POST',
      url: "question_save.php",
      data: {myJson:  JSON.stringify(jsonArray)},
      success: function(data){
  
          alert(data);
  
      }
  });
  </code></pre>
  
  <p>The string sent to the PHP looks like this:</p>
  
  <pre><code>[{"content":"Question text"},{"answerContent":"Some answer text","score":"234","responseChecked":0,"responseContent":""},{"answerContent":"","score":"0","responseChecked":0,"responseContent":""}]
  </code></pre>
  
  <p>If I echo $_POST['myJson'] I get this:</p>
  
  <pre><code>[{\"content\":\"Question text\"},{\"answerContent\":\"Some answer text\",\"score\":\"234\",\"responseChecked\":0,\"responseContent\":\"\"},{\"answerContent\":\"\",\"score\":\"0\",\"responseChecked\":0,\"responseContent\":\"\"}]
  </code></pre>
  
  <p>Yet when I want to decode the JSON and loop through it like this...</p>
  
  <pre><code>$json = $_POST['myJson'];
  $data = json_decode($json, true);
  
  foreach ($data as &amp;$value) {
      echo("Hi there");
  }
  </code></pre>
  
  <p>...I get this error:</p>
  
  <pre><code>Warning:  Invalid argument supplied for foreach() in /home/thecrime/public_html/test1/question_save.php on line 15
  </code></pre>
  
  <p>I really don't understand what silly mistake I'm making, is it something to do with the back slashes?</p>
  
  <p>Any help much appreciated!</p>
  
  <p>Thanks,
  -Ben</p>