public
function
array_unique_2DArr(
$arr
=
array
()){
if
(
empty
(
$arr
) || !
is_array
(
$arr
)){
return
array
();
}
$hasUniqueId
= false;
foreach
(
$arr
as
$val
){
if
(
array_key_exists
(
'uniqueId'
,
$val
)){
$hasUniqueId
= true;
break
;
}
}
if
(
$hasUniqueId
){
foreach
(
$arr
as
$_k
=>
$_val
){
if
(!
array_key_exists
(
'uniqueId'
,
$_val
)){
$_val_keys
=
array_keys
(
$_val
);
$_val_vals
=
array_values
(
$_val
);
array_unshift
(
$_val_keys
,
'uniqueId'
);
array_unshift
(
$_val_vals
,
'0_0'
);
$arr
[
$_k
] =
array_combine
(
$_val_keys
,
$_val_vals
);
}
}
}
foreach
(
$arr
[0]
as
$k
=>
$v
){
$arr_inner_key
[]=
$k
;
}
foreach
(
$arr
as
$k
=>
$v
){
$v
=join(
"^"
,
$v
);
$temp
[
$k
] =
$v
;
}
$temp
=
array_unique
(
$temp
);
foreach
(
$temp
as
$k
=>
$v
){
$a
=
explode
(
"^"
,
$v
);
$arr_after
[
$k
]=
array_combine
(
$arr_inner_key
,
$a
);
}
return
$arr_after
;
}