Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.