php multi-dimensional array remove duplicate -
Ensure that there is a duplicate in the need to delete this question, but I can not find the answer elsewhere so I
I have a 2D array that looks as follows:
Array ([0] => Array ([0] => Dave [1] = & Jones [2] => c @ bc) [1] => Hey ([0] => John [1] => Jones [2] => A @ BC) [2] = & gt; Array ([0] => Bruce [1] = & gt; Finkle [2] => c @ bc))
I want Remove people with duplicate emails, therefore sub In Okt example I will take just [] [0] or [] [2]. I do not have to worry about checking names or something like that, I just need a DPD depip based on the same value.
At the moment I have something like this
if (is_array ($ array) & count ($ array)> 0) {foreach ($ subarray $ Array as] {$ duplicate email [$ subarray [2]] = isset ($ duplicate email [$ subarray [2]]); Not set ($ duplicateEmail [$ subarray [2]]); }}
But this is not correct. Any help appreciated.
A quick solution that uses the specification of the array index:
< Code> $ newArr = array (); Foreign Currency ($ ARL $ Val) {$ newArr [$ val [2]] = $ val; } $ Array = array_values ($ newArr);
Notice 1: When appearing from above, the last match is used for an email address instead of the first one. This second row is
foreach Can be changed by changing it (array_reverse ($ array) as $ val) {
Notice 2: The resultant array is somewhat mixed in directions, but I think that makes a difference Do not ...
Comments
Post a Comment