3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $object = array( 'key' => 'value', 1 => 'value', '11' => 'value', '22' => 'value' ); $object = (object) $object; var_dump($object); print_r($object); $object->key = 'changed value'; $object->{1} = 'changed value'; $object->{'11'} = 'changed value'; $object->{'22'} = 'changed value'; $object = (array) $object; var_dump($object); print_r($object);
Output for 5.0.0 - 7.1.0
object(stdClass)#1 (4) { ["key"]=> string(5) "value" [1]=> string(5) "value" [11]=> string(5) "value" [22]=> string(5) "value" } stdClass Object ( [key] => value [1] => value [11] => value [22] => value ) array(7) { ["key"]=> string(13) "changed value" [1]=> string(5) "value" [11]=> string(5) "value" [22]=> string(5) "value" ["1"]=> string(13) "changed value" ["11"]=> string(13) "changed value" ["22"]=> string(13) "changed value" } Array ( [key] => changed value [1] => value [11] => value [22] => value [1] => changed value [11] => changed value [22] => changed value )
Output for 4.3.3 - 4.4.9
Fatal error: Property name must be a string in /in/V6lD1 on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.2
object(stdClass)(4) { ["key"]=> string(5) "value" [1]=> string(5) "value" [11]=> string(5) "value" [22]=> string(5) "value" } stdClass Object ( [key] => value [1] => value [11] => value [22] => value )
Process exited with code 139.