0

I need to find and count duplicate values after post the array

foreach ($_POST["marks"] as $marks => $value) {

need to display duplicate values and their count here

}

please help

Nick
  • 29
  • 4
  • Duplicate there are many questions asked in stackoverflow itself regarding this. [Stack overflow display only duplicate elements](http://stackoverflow.com/questions/1259407/php-return-only-duplicated-entries-from-an-array) – Harigovind R Jun 11 '15 at 06:35
  • but reason is I need to count duplicate values inside the foreach loop,,,Please give me solution for above code – Nick Jun 11 '15 at 06:38
  • In the link i gave check the answer given by bucabay and shiva – Harigovind R Jun 11 '15 at 06:40
  • [try this one](http://stackoverflow.com/questions/3450022/check-and-return-duplicates-array-php) – Harigovind R Jun 11 '15 at 06:47

1 Answers1

-1

http://us2.php.net/manual/en/function.array-count-values.php

<?php
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
?>

output

Array
(
    [1] => 2
    [hello] => 2
    [world] => 1
)
c4pone
  • 777
  • 7
  • 17