First of all this is not a duplicate question as i have tried most of the stack answer.
I have about 138886
records in my array.
records are like
[1] => Array
(
[country] => US
[state] => Albama
[city] => Brest
[postcode] => 225001-225003
[shipping_info] => Delivery Available
[is_zip_range] => 1
[zip_from] => 225001
[zip_to] => 225003
)
[2] => Array
(
[country] => BY
[state] => Brest
[city] => Brest
[postcode] => 225001-225003
[shipping_info] => Delivery Available
[is_zip_range] => 1
[zip_from] => 225001
[zip_to] => 225003
)
I want to unique all record from postcode
value i have tried some method are
Method 1
$temp = array_unique(array_column($data, 'postcode'));
$filteredData = array_intersect_key($data, $temp);
but it is still giving duplicate value.
Method 2
$filteredData = array_map("unserialize", array_unique(array_map("serialize", $data)));
this is won't work
Method 3
function unique_multidim_array($array, $key) {
$temp_array = array();
$i = 0;
$key_array = array();
foreach($array as $val) {
if (!in_array($val[$key], $key_array)) {
$key_array[$i] = $val[$key];
$temp_array[$i] = $val;
}
$i++;
}
return $temp_array;
}
$details = unique_multidim_array($array,'postcode');
It is working but too slow taking about 2/3 mins.
let me know any other method i can use for unique array. help will be apprecitaed