Skip to content

Instantly share code, notes, and snippets.

@seeschloss
Created April 15, 2013 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seeschloss/5387979 to your computer and use it in GitHub Desktop.
Save seeschloss/5387979 to your computer and use it in GitHub Desktop.
<?php
$object = new stdClass();
$object->{'property'} = 'value 1';
$object->{'42'} = 'value 2';
$array = (array)$object;
var_dump($array);
//array(2) {
// ["property"]=> string(7) "value 1"
// ["42"]=> string(7) "value 2"
//}
var_dump($array['property']);
// string(7) "value 1"
var_dump($array['42']);
// PHP Notice: Undefined index: 42 in /home/mva/test.php on line 19
// NULL
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment