Please help me to filter out only duplicate values in array using php.Consider,
$arr1 = array('php','jsp','asp','php','asp')
Here I would prefer to print only
array('php'=>2,
'asp'=>2)
tried it by
print_r(array_count_values($arr1));
but, its getting count of each element.
OK, after the comments and rereading your question I got what you mean. You’re still almost there with
array_count_values():You just need to remove the entries that are shown as only occurring once:
EDIT: don’t want a loop? Use
array_filter()instead: