daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top