如何删除关联数组中的重复值

How to remove duplicate values in assoc array

我有一个关联数组。如果值首先出现,我想删除重复值。假设如果 DC-30 先出现,则删除关联数组中的所有 DC-30。如果 HSD-M 已经出现,则删除关联数组中的所有 HSD-M。如果有任何不同,我将在 while($row = mysql_fetch_assoc($result)) 中完成所有这些工作。有什么帮助吗?

string(5) "DC-30" 
string(5) "DC-30" 
string(10) "GigaDigHD2" 
string(11) "Turbo-Frame" 
string(5) "HSD-M" 
string(5) "HSD-M" 
string(5) "HSD-M" 
string(5) "HSD-M"

编辑:这些数组值不是硬编码的。它们来自数据库中的 table,这就是我要删除重复值的原因。

想要的输出是:

string(5)  "DC-30" 
string(10) "GigaDigHD2" 
string(11) "Turbo-Frame" 
string(5)  "HSD-M"

第二次编辑:

while($row = mysql_fetch_assoc($result))
{
    $tester_name = $row['tester_name'];
    $board_name = $row['board_name'];
    $config = $row['config'];
    $req_config = $row['configuration'];

    echo $bomb = array_unique($board_name, SORT_REGULAR); //Edited here

    $ex_req_config = explode(",", $req_config);
    $count_req_config =  count($ex_req_config);

    $match = 0;

    foreach($ex_req_config as $value)
    {
        $number = strlen($value);
        $arr = str_split($value, $number);

        if(in_array($config, $arr))
        {
            $match += 1;
            $match /= ($count_req_config / 100);
        }
    }

    /*  echo "<tr class = \"thisRow\">
                <td></td>
                <td></td>
                <td class = \"match\">$match%</td>
             </tr>";*/
}

如果查询本身内的分组不是一个选项,则在循环开始之前初始化一个数组并在循环内管理它:

$boards = [];

while ($row = mysql_fetch_assoc($result)) {
    // ...
    $boards[$board_name] = $board_name;
}

在循环结束时 $boards 将是一个包含所有唯一值的数组。