3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $profile = [ 'person' => [ 'name' => 'Jim DeLois', 'address' => [ 'street' => '400 Central Park West', 'citiy' => 'New York', 'state' => 'NY', 'zip' => 10025 ], 'pets' => [] ] ]; $cast_recursive = function ( $element ) use ( &$cast_recursive ) { return is_array( $element ) ? (object) array_map( $cast_recursive, $element ) : $element; }; // map_recursive var_dump( $cast_recursive( $profile ) );
based on OWrTe
Output for 5.4.1 - 7.2.0
object(stdClass)#5 (1) { ["person"]=> object(stdClass)#4 (3) { ["name"]=> string(10) "Jim DeLois" ["address"]=> object(stdClass)#2 (4) { ["street"]=> string(21) "400 Central Park West" ["citiy"]=> string(8) "New York" ["state"]=> string(2) "NY" ["zip"]=> int(10025) } ["pets"]=> object(stdClass)#3 (0) { } } }
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/VdNGK on line 3
Process exited with code 255.