3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $object = new stdClass(); $object->foo = 'abc'; $object->bar = 'def'; $list = $object; foreach( $list as $key => $value ) { if ( is_object( $value ) ) { $list[ $key ] = $value->$field; } else { $list[ $key ] = $value[ $field ]; } }
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: field in /in/lC3qS on line 13 Notice: String offset cast occurred in /in/lC3qS on line 13 Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/lC3qS:13 Stack trace: #0 {main} thrown in /in/lC3qS on line 13
Process exited with code 255.
Output for 5.4.5 - 5.6.28
Notice: Undefined variable: field in /in/lC3qS on line 13 Notice: String offset cast occurred in /in/lC3qS on line 13 Fatal error: Cannot use object of type stdClass as array in /in/lC3qS on line 13
Process exited with code 255.
Output for 5.4.0 - 5.4.4
Notice: Undefined variable: field in /in/lC3qS on line 13 Notice: String offset cast occured in /in/lC3qS on line 13 Fatal error: Cannot use object of type stdClass as array in /in/lC3qS on line 13
Process exited with code 255.
Output for 5.0.4 - 5.3.29
Notice: Undefined variable: field in /in/lC3qS on line 13 Fatal error: Cannot use object of type stdClass as array in /in/lC3qS on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: field in /in/lC3qS on line 13 Fatal error: Cannot use object of type stdClass as array in /in/lC3qS on line 13
Process exited with code 255.
Output for 4.3.0 - 4.4.9
Notice: Undefined variable: field in /in/lC3qS on line 13 Warning: Cannot use a scalar value as an array in /in/lC3qS on line 13 Notice: Undefined variable: field in /in/lC3qS on line 13 Warning: Cannot use a scalar value as an array in /in/lC3qS on line 13