Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function findRepeats($array){
- return array_filter(array_count_values($array), function($item) {
- if($item > 1){
- return $item;
- }
- });
- }
- $a = [0,1,2,3,4,5,5,5,6,6,7,8];
- foreach(findRepeats($a) as $key => $value){
- echo 'The "'.$key.'" element is repeated '.$value.' times in array <br>';
- }
Add Comment
Please, Sign In to add comment