title: PHP 5.4 code update - Creating default object from empty value warnings in foreach and objects array
body: <p>I have following code:</p>
  
  <pre><code>foreach($foo as $n=&gt;$ia) {
      foreach($ia as $i=&gt;$v) {
      $bar[$i]-&gt;$n = $v; //here I have 'Creating default object...' warning
      }
  }
  </code></pre>
  
  <p>If I add:</p>
  
  <pre><code>$bar[$i] = new stdClass;
  $bar[$i]-&gt;$n = $v;
  </code></pre>
  
  <p>to fix it. Then values in objects in array 'bar' not sets. For example, I have array:</p>
  
  <pre><code> $foo = array(
   "somefield" =&gt; array("value1", "value2", "value3"),
   "anotherfield" =&gt; array("value1", "value2", "value3")
   );
  </code></pre>
  
  <p>On output I should get:</p>
  
  <pre><code>$bar[0]-&gt;somefield = value1
  $bar[1]-&gt;anotherfield = value2
  </code></pre>
  
  <p>But in practice I get:</p>
  
  <pre><code>$bar[0]-&gt;somefield = null //(not set)
  $bar[1]-&gt;anotherfield = null //too
  </code></pre>
  
  <p>How should I update the code to get it work?</p>