array combine with duplicates keys php code example
Example 1: php get duplicate keys in array without using inbuilt function
$arr = array(3,5,2,5,3,9);
foreach($arr as $key => $val){
unset($arr[$key]);
if (in_array($val,$arr)){
echo $val . " ";
}
}
Example 2: php get keys of duplicate values in array
<?php
$array = array('a', 'a', 'b', 'c', 'd');
$unique = array_unique($array);
$duplicates = array_diff_assoc($array, $unique);
$result = array_diff($unique, $duplicates);
$unique_keys = array_keys($result);
$duplicate_keys = array_keys(array_intersect($array, $duplicates));