Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

WTF?

By: a guest on May 25th, 2012  |  syntax: PHP  |  size: 0.50 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.     $arr = array(
  3.         23 => array(
  4.             'foo' => 'bar',
  5.             'baz' => 'xyz'
  6.         ),
  7.         55 => array(
  8.             'foo' => 'bar',
  9.             'baz' => 'xyz'
  10.         ),
  11.     );
  12.  
  13.     print_r($arr);
  14.  
  15.     $serialized = json_encode($arr);
  16.     print_r($serialized);
  17.  
  18.     $stdclass = json_decode($serialized);
  19.     print_r($stdclass);
  20.  
  21.     $new_arr = (array) $stdclass;
  22.     print_r($new_arr);
  23.  
  24.     print_r($new_arr['23']);//error
  25.     print_r($new_arr[23]);//error
  26. ?>