匹配内爆数据与另一个内爆

I have data from two different tables where the data have been implode after being selected from Checkboxes and they are divided by a ','. After i selected them from the database the two varibles could look like this.

$firstvar = Red, Blue, Green, Yellow

$secondvar = Green, Purple, White

So i want to know how i can check, if there is a match, when there is at least one of the colors that match in the two variables.

i've been trying with:

if (strpos($firstvar , $firstvar ) !== false) {
    echo 'There is a match';
}

But it doesn't work.

After fetching the result from the database, explode these two variables:

Just like this:

$firstvar = explode(",",$firstvar);
$secondvar = explode(",",$secondvar );

Now, use this function:

$match = array_intersect($firstvar,$secondvar);

and now, implode the resulted output:

$result = implode(",",$match);
echo $result;

Hope, this may be useful to you.