xxxxxxxxxx
<?php
function super_unique($array){
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
foreach ($result as $key => $value){
if ( is_array($value) ){
$result[$key] = super_unique($value);
}
}
return $result;
}
?>
xxxxxxxxxx
<?php
function super_unique($array,$key)
{
$temp_array = [];
foreach ($array as &$v) {
if (!isset($temp_array[$v[$key]]))
$temp_array[$v[$key]] =& $v;
}
$array = array_values($temp_array);
return $array;
}
$arr="";
$arr[0]['id']=0;
$arr[0]['titel']="ABC";
$arr[1]['id']=1;
$arr[1]['titel']="DEF";
$arr[2]['id']=2;
$arr[2]['titel']="ABC";
$arr[3]['id']=3;
$arr[3]['titel']="XYZ";
echo "<pre>";
print_r($arr);
echo "unique*********************<br/>";
print_r(super_unique($arr,'titel'));
?>
xxxxxxxxxx
$uniquePids = array_unique(array_map(function ($i) { return $i['pid']; }, $holder));
Using array_unique with SORT_REGULAR will return all unique arrays within an array.
xxxxxxxxxx
$my_array=[
array(1,2,3),
array(1,2,3),
array(1,2,4),
array(1,2,5),
array(1,2,5)
];
$my_unique_array=array_unique($my_array,SORT_REGULAR);