How do I get an array of widgets?

How do I get an array of widgets?

You can look into

$sidebars_widgets =  wp_get_sidebars_widgets();
print_r( $sidebars_widgets );

Here’s an output example:

Array
(
    [orphaned_widgets_1] => Array
        (
            [0] => text-6
        )

    [wp_inactive_widgets] => Array
        (
            [0] => text-7
            [1] => rss-2
        )

    [sidebar-1] => Array
        (
            [0] => recent-posts-3
            [1] => recent-posts-4
            [2] => text-9
            [3] => calendar-2
            [4] => categories-3
            [5] => search-4
            [6] => text-8
            [7] => categories-2
        )

    [sidebar-2] => Array
        (
            [0] => search-5
        )

    [sidebar-3] => Array
        (
            [0] => recent-posts-2
        )

)