title: PHP Fatal error: Cannot use string offset as an array
body: <p>Facing a weird situation with arrays..
  I am using LinkedIn API to get profile info which returns data in two formats..</p>
  
  <p>If user has just one educational item</p>
  
  <pre><code>educations=&gt;education=&gt;school-name
  educations=&gt;education=&gt;date
  ...
  </code></pre>
  
  <p>If more than one education item</p>
  
  <pre><code>educations=&gt;education=&gt;0=&gt;school-name
  educations=&gt;education=&gt;0=&gt;date
  ...
  educations=&gt;education=&gt;1=&gt;school-name
  educations=&gt;education=&gt;1=&gt;date
  ...
  </code></pre>
  
  <p>Now I am trying to make it consistent and convert</p>
  
  <pre><code>educations=&gt;education=&gt;school-name
  </code></pre>
  
  <p>to</p>
  
  <pre><code>educations=&gt;education=&gt;0=&gt;school-name
  </code></pre>
  
  <p>But getting error in code that i believe should work</p>
  
  <pre><code>if(empty($educations['education'][0]['school-name']))
  {
      $temp = array();
      $temp['education'][0]=$educations['education'];
      $educations = $temp;
  }
  </code></pre>
  
  <p>This fails for "just one educational item", generates error on the first line for (isset,is_array and empty)</p>
  
  <pre><code>PHP Fatal error:  Cannot use string offset as an array in ...
  </code></pre>
  
  <p>print_r returns</p>
  
  <pre><code>[educations] =&gt; Array
      (
          [education] =&gt; Array
              (
                       [id] =&gt; 109142639
                       [school-name] =&gt; St. Fidelis College
                       [end-date] =&gt; Array
                           (
                               [year] =&gt; 2009
                           )
  
              )
  
      )
  </code></pre>