I would like to get only the values that are duplicated in the array
I'm trying to do this:
$cdCursos = array(1, 2,3,4,5,3 );
echo "<pre>";
print_r( $cdCursos );
echo "</pre>";
$withoutDup = array_unique($cdCursos);
echo "<pre>";
print_r( $withoutDup );
echo "</pre>";
$duplicates = array_diff($cdCursos, $withoutDup);
echo "<pre>";
print_r( $duplicates );
echo "</pre>";
The values are thus returning, respectively:
Array ( [0] => 1 1 => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 3 )
Array
(
[0] => 1
1 => 2
[2] => 3
[3] => 4
[4] => 5
)
</pre><pre>Array
(
)
I tried this , but it did not work.