How to loop over wp_get_themes() and create an array of themes name

Correct the wp_get_themes() function has most of the information inaccessible to the public which requires you to pull the info out using the $theme->get( 'Name' ); format. You can build a simple array like so.

// Build new empty Array to store the themes
$themes = array();

// Loads theme data
$all_themes = wp_get_themes();

// Loads theme names into themes array
foreach ($all_themes as $theme) {
  $themes[] = $theme->get('Name');
}

// Prints the theme names
print_r( $themes );

Which will output

Array (
  [0] => Anchor Blank
  [1] => Swell - Anchor Hosting
  [2] => Swell
)

Taking this one step future you can build an array with all of the theme data like so.

// Build new empty Array to store the themes
$themes = array();

// Loads theme data
$all_themes = wp_get_themes();

// Build theme data manually
foreach ($all_themes as $theme) {
  $themes{ $theme->stylesheet } = array(
    'Name' => $theme->get('Name'),
    'Description' => $theme->get('Description'),
    'Author' => $theme->get('Author'),
    'AuthorURI' => $theme->get('AuthorURI'),
    'Version' => $theme->get('Version'),
    'Template' => $theme->get('Template'),
    'Status' => $theme->get('Status'),
    'Tags' => $theme->get('Tags'),
    'TextDomain' => $theme->get('TextDomain'),
    'DomainPath' => $theme->get('DomainPath')
  );
}

// Prints the themes
print_r( $themes );

This will output an array which looks like the following

Array (
[anchor-blank] => Array
    (
        [Name] => Anchor Blank
        [Description] => Anchor Hosting blank theme
        [Author] => Anchor Hosting
        [AuthorURI] => https://anchor.host
        [Version] => 1.1
        [Template] =>
        [Status] => publish
        [Tags] => Array
            (
            )

        [TextDomain] => anchor-blank
        [DomainPath] => /languages/
    )

[swell-anchorhost] => Array
    (
        [Name] => Swell - Anchor Hosting
        [Description] => Child theme for Anchor Hosting
        [Author] => Anchor Hosting
        [AuthorURI] => https://anchor.host
        [Version] => 1.1.0
        [Template] => swell
        [Status] => publish
        [Tags] => Array
            (
            )

        [TextDomain] => swell
        [DomainPath] => /languages/
    )

[swell] => Array
    (
        [Name] => Swell
        [Description] => Swell is a one-column, typography-focused, video WordPress theme.
        [Author] => ThemeTrust.com
        [AuthorURI] => http://themetrust.com
        [Version] => 1.2.6
        [Template] =>
        [Status] => publish
        [Tags] => Array
            (
            )

        [TextDomain] => swell
        [DomainPath] => /languages/
    )
)