I have a series of user data which each one is a list of comma separate values like italian, english
. So first of all I want to list each of them and that it is fine and works. But these values could be repeated and it is ok yet I would like to know the number of the repeat values in order to be able to says: American = 2
. The code below shows me
Duplicates count: 5
But actually I should have only 2 duplicates as I can see from the admin panel
$stack = array();
$blogusers = get_users( 'orderby=nicename&role=author' );
foreach ( $blogusers as $user ) {
$descTokens = explode(',', $user->user_description);
$stack = array_merge($stack, $descTokens);
}
$count_values = array();
foreach ($stack as $a) {
@$count_values[$a]++;
}
echo 'Duplicates count: '.count($count_values);
If I do print_r($count_values)
i get
Array ( [francese] => 1 [ matematica] => 2 [ inglese] => 1 [fisica] => 1 [ latino] => 1 ) Duplicates count: 5
And those aren't repeated strings