Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅回显数组\u count\u值结果的重复值_Php_Arrays_Sorting_Duplicates - Fatal编程技术网

Php 仅回显数组\u count\u值结果的重复值

Php 仅回显数组\u count\u值结果的重复值,php,arrays,sorting,duplicates,Php,Arrays,Sorting,Duplicates,在我和一个朋友连续搜索了几个小时,尝试了许多事情之后,我们无法找到如何只回显数组_count _值结果的重复值。我会把它分解: 我们有许多选择框,通过GET发送时可构建阵列,例如: <div class="form-group col-sm-2 mb-sm"> <select name="select[]" class="form-control"> <option value="" disabled=

在我和一个朋友连续搜索了几个小时,尝试了许多事情之后,我们无法找到如何只回显数组_count _值结果的重复值。我会把它分解:

我们有许多选择框,通过GET发送时可构建阵列,例如:

    <div class="form-group col-sm-2 mb-sm">
            <select name="select[]" class="form-control">
                <option value="" disabled="" selected="">Select</option>
                <option value="optionOne">Option 1</option>
                <option value="optionTwo">Option 2</option>
            </select>
        </div>
        <div class="form-group col-sm-2 mb-sm">
            <select name="select[]" class="form-control">
                <option value="" disabled="" selected="">Select</option>
                <option value="optionOne">Option 1</option>
                <option value="optionTwo">Option 2</option>
            </select>
        </div>
        <div class="form-group col-sm-2 mb-sm">
            <select name="select[]" class="form-control">
                <option value="" disabled="" selected="">Select</option>
                <option value="optionOne">Option 1</option>
                <option value="optionTwo">Option 2</option>
            </select>
        </div>
我们尝试了foreach循环,但似乎无法使其工作

任何帮助都将不胜感激


亲切问候

我认为下面的代码有助于您获得重复值

$array = array(1=>'12334',2=>'123345',3 =>'Helloo' ,4=>'hello', 5=>'helloo');

// Convert every array value to uppercase, and remove all duplicate values
$notdublicates = array_unique(array_map("strtoupper", $array));

// The difference in the original array $array, and the $notdublicates array
// will be the duplicate values
$getduplicates = array_diff($array, $notdublicates);
print_r($getduplicates);

我认为下面的代码有助于您获得重复值

$array = array(1=>'12334',2=>'123345',3 =>'Helloo' ,4=>'hello', 5=>'helloo');

// Convert every array value to uppercase, and remove all duplicate values
$notdublicates = array_unique(array_map("strtoupper", $array));

// The difference in the original array $array, and the $notdublicates array
// will be the duplicate values
$getduplicates = array_diff($array, $notdublicates);
print_r($getduplicates);
试试这个

$array = array("test", "hello", "test", "world", "hello");

$duplicatedValuesArray = array_keys(array_filter(array_count_values($array), function($v) {
    return $v > 1;
}));

echo implode(', ',$duplicatedValuesArray);
试试这个

$array = array("test", "hello", "test", "world", "hello");

$duplicatedValuesArray = array_keys(array_filter(array_count_values($array), function($v) {
    return $v > 1;
}));

echo implode(', ',$duplicatedValuesArray);

可以在此处发布get参数$\u get['select']数组值,您只需循环数组计数值的结果,并输出值大于1的所有键。@JYoThI我已编辑了后发布变量转储($\u get['select'])@DisplayName@JYoThI谢谢你,但我已经接受了一个答案,我本以为你可以告诉我从我添加到帖子中的选择框中的var\u dump将输出什么,对不起。你可以在这里发布你的get参数$\u get['select']array value,你所要做的就是循环数组计数值的结果,并输出值大于1的所有键。@JYoThI我已经编辑了后租赁后var_转储($\u GET['select'])@DisplayName@JYoThI谢谢你,但我已经接受了一个答案,我想你可以从我添加到帖子中的选择框中知道var_转储将输出什么,对不起。这太完美了,谢谢你。我会投赞成票,但有人出于某种原因投了我的票,甚至没有提到原因,所以我现在只有不到15名代表。这太完美了,谢谢。我会投赞成票,但有人出于某种原因投了我的票,甚至没有提到原因,所以我现在只有不到15名代表。。。