<?PHP function arrayToObject( $array ) { $object = new stdClass(); foreach( $array as $key => $value ) { if( is_array( $value ) ) { $object->$key = arrayToObject( $value ); } else { $object->$key = $value; } } return $object; } ?>
<?PHP $array = array( "vorname" => "Damir", "nachname" => "Enseleit" ); $array[0] = "SELFPHP"; $array[1] = "www.selfphp.de"; $object = arrayToObject($array); echo $object->vorname . "\n"; echo $object->nachname . "\n"; echo $object->{'0'} . "\n"; echo $object->{'1'} . "\n"; ?>