Guest User

Untitled

a guest
Jan 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. <?php
  2.  
  3. function findRepeats($array){
  4. return array_filter(array_count_values($array), function($item) {
  5. if($item > 1){
  6. return $item;
  7. }
  8. });
  9. }
  10.  
  11. $a = [0,1,2,3,4,5,5,5,6,6,7,8];
  12. foreach(findRepeats($a) as $key => $value){
  13. echo 'The "'.$key.'" element is repeated '.$value.' times in array <br>';
  14. }
Add Comment
Please, Sign In to add comment