我有一个多维数组:
Array
(
[0] => Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
)
[1] => Array
(
[a] => 1
[b] => 5
[c] => 3
[d] => 4
)
[2] => Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
)
)
看第一索引(或零)和第三索引(第二索引)在,在A,B,C的值,d是等于1,2,3,4。 假设阵列是相等的,或没有什么不同它们; 我的问题是,我怎么能抓住这等于阵列,我的目的是显示有关值输入重复的用户,
使用我已经array_unique
。 这是结果:
Array
(
[0] => Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
)
[1] => Array
(
[a] => 1
[b] => 5
[c] => 3
[d] => 4
)
)
但我只是想重复的数据,不删除数据副本。
// first : get all data, if the data same / duplicate take only one data
$unique = array_unique($data, SORT_REGULAR);
// then, get the data which duplicate with
$diffCellUniq = array_diff_key($data, $unique);
// so print the result
print_r($diffCellUniq); exit;
Array
(
[2] => Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
)
)