Created
April 15, 2013 13:15
-
-
Save seeschloss/5387979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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