title: PHP: cast to (array) and return-type: array is not the same?
body: <p>I have following problem in PHP:</p>
  
  <p><code>print_r()</code> says it's the same, <code>gettype()</code> says same type, but the last output works not for both cases although they should be the same!</p>
  
  <p>This looks very strange to me.</p>
  
  <p>code and output:</p>
  
  <pre><code>$docdatau = get_object_vars(json_decode($docdata));
  $docdatau2 = (array)json_decode($docdata);
  
  echo "1\n";
  echo gettype($docdatau);
  echo "\n";
  echo "--------------------------------------\n";
  print_r($docdatau);
  echo "--------------------------------------\n";
  
  echo "2\n";
  echo gettype($docdatau2);
  echo "\n";
  echo "--------------------------------------\n";
  print_r($docdatau2);
  
  echo "out1\n";
  echo "--------------------------------------\n";
  print_r($docdatau[0]);
  echo "out2\n";
  echo "--------------------------------------\n";
  print_r($docdatau2[0]);
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>1
  array
  --------------------------------------
  Array
  (
  
      [0] =&gt; stdClass Object
          (
              [produkt] =&gt; Produkt 2
              [laufzeit] =&gt; 24
              [addtext] =&gt; sdsd
              [provision] =&gt; 39
          )
  
      [1] =&gt; stdClass Object
          (
              [produkt] =&gt; Produkt 1
              [laufzeit] =&gt; 
              [addtext] =&gt; 
              [provision] =&gt; 0
          )
  
  )
  --------------------------------------
  2
  array
  --------------------------------------
  
  Array
  (
  
      [0] =&gt; stdClass Object
          (
              [produkt] =&gt; Produkt 2
              [laufzeit] =&gt; 24
              [addtext] =&gt; sdsd
              [provision] =&gt; 39
          )
  
      [1] =&gt; stdClass Object
          (
              [produkt] =&gt; Produkt 1
              [laufzeit] =&gt; 
              [addtext] =&gt; 
              [provision] =&gt; 0
          )
  
  )
  out1
  --------------------------------------
  stdClass Object
  (
      [produkt] =&gt; Produkt 2
      [laufzeit] =&gt; 24
      [addtext] =&gt; sdsd
      [provision] =&gt; 39
  )
  out2
  --------------------------------------
  --------------------------------------
  </code></pre>
  
  <p><code>out1</code> and <code>out2</code> should produce the same results but don't.</p>
  
  <p>Perhaps anybody has a hint for me?</p>