There is a magical function PHP is offering to you it called in_array().
Using parts of your code we will modify the loop as follows:
<?php
$array = array(12,43,66,21,56,43,43,78,78,100,43,43,43,21);
$arr2 = array();
$counter = 0;
for($arr = 0; $arr < count($array); $arr++){
if (in_array($array[$arr], $arr2)) {
++$counter;
continue;
}
else{
$arr2[] = $array[$arr];
}
}
echo 'number of duplicates: '.$counter;
print_r($arr2);
?>
The above code snippet will return the number total number of repeated items i.e. form the sample array 43 is repeated 5 times, 78 is repeated 1 time and 21 is repeated 1 time, then it returns an array without repeat.