Use this code:
# assuming your original array is $arr
array_unique(array_diff_assoc($arr, array_unique($arr)));
It will return unique duplicates but if you want non-unique duplicates then use:
array_diff_assoc($arr, array_unique($arr));
EDIT: Based on your comments, try this code:
$uarr = array_unique($arr);
var_dump(array_diff($arr, array_diff($uarr, array_diff_assoc($arr, $uarr))));
OUTPUT
array(4) {
[5]=>
string(5) "Ahmed"
[6]=>
string(5) "Ahmed"
[7]=>
string(4) "Ajay"
[8]=>
string(4) "Ajay"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…