fork download
  1. <?php
  2. $array = array(1=>10,11,12,12,12,13,13);
  3.  
  4. $arr_duplicates = array();
  5. foreach($array as $k=>$v){
  6. $first_index = array_search($v, $array);
  7. if($k != $first_index){
  8. $arr_duplicates[$k] = $first_index;
  9. }
  10. }
  11.  
  12. var_dump($arr_duplicates);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(3) {
  [4]=>
  int(3)
  [5]=>
  int(3)
  [7]=>
  int(6)
}