1
I would like to get only the values that are duplicated in the array
I’m trying to do it like 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 returning so, 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 to that one answer, but it did not work
Good, boy! Exactly what I wanted. Thank you very much
– adventistaam