How to list the taxonomy terms that fit the custom query?

Get this recipe’s assigned terms (recipe having $recipe_id):

$terms_arr = [];
$terms_objs = get_the_terms($recipe_id, 'main_ingredient');
if ($terms_objs) {
    foreach ($terms_objs as $term_obj) {
        $terms_arr[] = $term_obj->slug;
    }
}

Find the terms found in both arrays:

$the_ingrediens = array_intersect($ingredients, $terms_arr);