WordPress - 列出数组中的菜单数据?

How can I get my menus in an array?

With wp_nav_menu ( );, I will get the list with HTML, but I don't want the HTML tags. I just want the data.

I found this but what is this line for - $menu_name = 'custom_menu_slug';?

    $menu_name = 'custom_menu_slug'; // Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)

    if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );

    $menu_items = wp_get_nav_menu_items($menu->term_id);


        foreach ( (array) $menu_items as $key => $menu_item ) {
            $title = $menu_item->title;
        }
    }

Any ideas?

It sounds like wp_get_nav_menu_items should do it. If you just want the menu items in an array, you don't need the rest of the code you have there.