Skip to content

Instantly share code, notes, and snippets.

@blerou
Created January 26, 2013 14:33
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 blerou/4642736 to your computer and use it in GitHub Desktop.
Save blerou/4642736 to your computer and use it in GitHub Desktop.
$ php -a
Interactive shell
php > $obj = new stdClass;
php > $numKey = 123;
php > $obj->{$numKey} = 'foo';
php > $ary = (array) $obj;
php > var_dump($obj, $ary);
class stdClass#1 (1) {
public $123 =>
string(3) "foo"
}
array(1) {
'123' =>
string(3) "foo"
}
php > var_dump($ary[123]);
NULL
php > var_dump($ary['123']);
NULL
php >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment