基于值选择数组-PHP

基于值选择数组-PHP,php,arrays,Php,Arrays,代码是用php编写的。我有很多类似的数组 Array ( [0] => HLA-A11 [1] => HLA-class II ) Array ( [0] => HLA-class II [1] => HLA-class I ) Array ( [0] => HLA-class II [1] => HLA-A14 ) Array ( [0] => HLA-A2 [1] => HLA-A24 ) Array ( [0] => HLA-class

代码是用php编写的。我有很多类似的数组

Array ( [0] => HLA-A11 [1] => HLA-class II )
Array ( [0] => HLA-class II [1] => HLA-class I )
Array ( [0] => HLA-class II [1] => HLA-A14 )
Array ( [0] => HLA-A2 [1] => HLA-A24 )
Array ( [0] => HLA-class I )
我想选择不包含该值(HLA class II或HLA class I)或包含一个或两个值但包含其他值(不同于HLA class I和HLA class II)的数组。在这里,我将选择数组编号1,3,4。基本上,我想放弃只包含HLA I类或HLA II类或两者的数组

我一直在使用类似于,$mhc_res_pos是带有要比较的值的数组,$final_data是用于存储所选等位基因的数组

if(in_array('HLA-class II',$mhc_res_pos)){

}
else{
    array_push($final_data, $mhc_res_pos);
}

谢谢

您可以使用
数组过滤器
轻松完成此操作

$arrayTmp = array_filter($array, function ($value) {
    if ($value == 'Remove this' || $value == 'Remove that') 
        return false;
    return true;
});

if (empty($arrayTmp)) {
    // Discard $array
} else {
    // Keep $array
}
但我不确定“放弃阵列”是什么意思。

谢谢?我们不会写你的代码!向我们展示您的尝试,我们将帮助您修复代码