title: PHP Array Warning: Creating default object from empty value
body: <p>I have taken values from a MySQL query into an array so that I can sort them.  It all works well except I am getting lots of errors </p>
  
  <pre><code> Warning: Creating default object from empty value 
  </code></pre>
  
  <p>This is so that I can sort the array based on post_id and quality</p>
  
  <pre><code>$count = 0;
  $searcharticles = new stdClass();
  $postid = 0;
  while ($row = mysqli_fetch_object($result1) ) {
  
      $postid     = $row-&gt;ID;
      $title      = $row-&gt;post_title;
      $titlescore = $row-&gt;titlescore;
      $quality    = $row-&gt;quality;
  
      $searcharticles-&gt;$postid-&gt;post_id =$postid;
      $searcharticles-&gt;$postid-&gt;title =$title;
      $searcharticles-&gt;$postid-&gt;titlescore = $titlescore;
      $searcharticles-&gt;$postid-&gt;quality =$quality;
  
  $count ++;
  } 
  </code></pre>
  
  <p>Some posts on Stackexchange indicated that I should add in 
      $searcharticles = new stdClass();</p>
  
  <p>But this has not solved the problem</p>
  
  <p>I am looking to remove the errors and not just suppress the warnings.</p>
  
  <p>Any ideas?</p>