How to use foreach and if statement within array of arrays?

Figured it out as per this answer.

You cannot put any loop or control structure if/else as array value or anywhere within array().

Example

$contact_list = [];
$contact_list['url'] = 'Website';
foreach ( wp_get_user_contact_methods() as $value => $label ) { 
    $contact_list[$value] = $label;
}
$settings_fields = array( // Parent array
    'dsbl_basics' => array( // Child array
        array( // Child's child array
            'name' => 'text_val',
            'label' => 'Text Input'
        )
    ),
    'dsbl_profile' => array( // Child array
        array( // Child's child array
            'name' => 'name',
            'label' => 'dsbl',
            'options' => array(
                'first_name' => 'First Name',
                'last_name' => 'Last Name'
            )
        ),
        array( // Child's child array
            'name' => 'contact_info',
            'label' => 'Contact Info', 
            'options' => $contact_list
        )
    )
);
$yoast_plugin = array( // Child's child array
    'name' => 'yoast_seo',
    'label' => 'Yoast SEO', 
    'options' => array(
        'wpseo_author_title' => 'Title to use for Author page',
        'wpseo_author_metadesc' => 'Meta description to use for Author page'
    )
);
if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) {
    $settings_fields['dsbl_profile'][1] = $yoast_plugin;
}