Unable to return values from function

The foreach surrounding your return line means only the first item will be returned – perhaps that’s what you want?

If not, then you should assign $value[2] to a local variable (concatenating if you want a string, or an array perhaps?) and the return the local variable after the loop.

function get_admin_menus() {
    global $submenu, $menu, $pagenow;
    $r="";
    if ( current_user_can('manage_options') ) {
        if( $pagenow == 'index.php' ) {
        foreach ( $submenu as $index => $menu_item ) {
            foreach ( $menu_item as $value ) {
                    $r .= $value[2];
                }
            }
        }
    }
    return $r;
}