Generating $args array with tags from a submitted form

Hi everyone, I have tried for hours to resolve this. I have a search form querying the databse that I am getting multiple values from with a checkbox. I can easily iterate through these values with a php foreach after the form submits and it shows me all the values I have selected.

The values are a list of tags, and the user can choose more than one. The problem is that I don’t know how to show this list of tags in my $args array. It isn’t working properly and I don’t know why. Please note: array($tag_names). I don’t know how to iterate through the tag_slugs so they show up like this: ‘tag_slug__and’ => tag1, tag2, tag3

$args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'category_name' => $main_cat,
'tag_slug__and' => array($tag_slugs),
    'posts_per_page' => 5,
);

Please help anyone who knows what I am doing wrong here.

Is it not just a variation on

foreach ($args['tag_slug__and'] as $ix=> $vl) {
    echo $ix;
    echo $vl;
}

or am I misunderstanding the question?