3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(45, 5, 1, 22, 22, 10, 10); //use array_count_values to counts all the values of an array. $get_repeated_value = array_count_values($array); $final_array = array(); foreach($get_repeated_value as $key => $value){ //If value is repeated, get the index of that values from array. if($value > 1){ $final_array[$key] = array_keys($array, $key); } } echo "<pre>"; print_r($final_array); ?>

preferences:
23.91 ms | 406 KiB | 5 Q