title: JSON to PHP array getting "Trying to get property of non-object in" Error
body: <p>Hello I have Json like this:</p>
  
  <pre><code>[{
      "exam_code": "1",
      "name": "Name1",
      "surname": "Surname1",
      "father_name": "Fname1",
      "id_number": "211111",
      "district_number": "21",
      "school_number": "025",
      "gender": "F",
      "variant": "A",
      "grade": "4",
      "sector": "A",
      "foreign_language": "I",
      "answerList": {
          "gradeFour": {
              "lesson1": ["A", "C", "C", "C", "A", "A", "B", "B", " ", "C", "C", "B", "A", "C", "C", "B", "B", "C", "B", "A"],
              "lesson2": ["B", "A", " ", "C", " ", "B", " ", "B", "B", "C", " ", " ", "B", "A", "A", "A", "C", "A", "B", "B"],
              "lesson3": ["A", "C", "B", "B", "A", "A", "C", "A", "C", "C"],
              "lesson4": ["B", "B", "A", "B", "B"],
              "lesson5": ["B", "A", "A", "B", "B"],
              "lesson6": ["B", "A", "A", "B", "A", "B", "A", "A", "C", "B"]
          }
      }
  }]
  </code></pre>
  
  <p>I am trying to print out lessons answers on foreach loop.</p>
  
  <p>tried below code:</p>
  
  <pre><code>&lt;?php
  $msc = microtime(true);
  
  
  $array = (json_decode($raw_str,true));
  
  foreach($array as $value){
  echo $value['id_number'];
      echo '&lt;br/&gt;';
  
     foreach($value -&gt; answerList-&gt;gradeFour as $val){
          echo $val;    
    }
  
    echo '&lt;br&gt;---------------------------';
    echo '&lt;br&gt;';
  
  }
  $msc = microtime(true)-$msc;
  echo ($msc * 1000) . ' ms'; // in millseconds
  ?&gt;
  </code></pre>
  
  <p>But getting this error</p>
  
  <blockquote>
    <p>Notice: Trying to get property of non-object in
    G:\xampp\htdocs\siec\string_test.php on line 50 Notice: Trying to get
    property of non-object in G:\xampp\htdocs\siec\string_test.php on line
    50 Warning: Invalid argument supplied for foreach() in
    G:\xampp\htdocs\siec\string_test.php on line 50</p>
  </blockquote>