I know how to detect duplicate value in PHP array by using array_diff_key( $x , array_unique( $x ) );.
My problem is I want to detect duplicate value in PHP array, but ignore a value or NULL value. For example:
$x = array (1,0,0,0,4,4,3);
$x = array (1,NULL,NULL,NULL,4,4,3);
I want to detect 4 without changing the array structure (array length must still 7). Is this possible in PHP ? How to do that?
Is this possible in PHP ?yes, it is possible with phparray_intersect_assocarray_filterto remove the values you want to ignore before checking for duplicates. None of these functions change the original array structure, they return new arrays.