foreach中的strpos只检查最后一个数组

I made a simple program for checking weather a string is contain in a variable or not with strpos but when I am checking this I found that it is only checking the last array.

Here is my php

$branda = $_GET['brand'];
$brandq = $row['company'];
$my3 = array($brandq);

foreach($my3 as $map){
    $mane=strpos($branda,$map);

    if($mane !== false)
    {
        $myfunction2 = "'".str_replace(",","','",$branda)."'";
        $condition2='and product.company IN('.$myfunction2.') ';
    } else {
        $condition2='';
    }
}

I have made some assumptions:

// Assumptions
$row['company'] = array("apple","samsung","microsoft","sony");
$_GET['brand']  = "microsoft";

This code should be correct:

$branda = $_GET['brand'];
$brandq = $row['company'];
$condition2 = "";

foreach ($brandq as $map) {
    $mane = strpos($branda,$map);

    if ($mane !== false) {
        $myfunction2 = "'".str_replace(",","','",$branda)."'";
        $condition2 .='and product.company IN('.$myfunction2.') ';
    }
}

Echo out the result:

echo $condition2 . PHP_EOL;

Output: and product.company IN('microsoft')

I have made some assumptions:

// Assumptions
$row['company'] = array("apple","samsung","microsoft","sony");
$_GET['brand']  = "microsoft";

This code should be correct:

$branda = $_GET['brand'];
$brandq = $row['company'];
$condition2 = "";

foreach ($brandq as $map) {
    $mane = strpos($branda,$map);

    if ($mane !== false) {
        $myfunction2 = "'".str_replace(",","','",$branda)."'";
        $condition2 .='and product.company IN('.$myfunction2.') ';
    }
}

Echo out the result:

echo $condition2 . PHP_EOL;

Output: and product.company IN('microsoft')