Posted By

stz184 on 10/09/10


Tagged

check array duplicates


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

beebs93
bobbym245


Check for duplicate element in array


 / Published in: PHP
 

Parameters: $array - haystack, $find-value - needle to check for duplicates

  1. function count_duplicates($array, $find_value) {
  2. $counter = 0;
  3. foreach($array as $value) {
  4. if($value == $find_value) {
  5. $counter++;
  6. }
  7. }
  8. return $counter;
  9. }

Report this snippet  

You need to login to post a comment.