Reputation: 1
I have a some data stored in $data[], there are some items in it. How do I remove duplicate values in a foreach?
Array
(
[0] => ABC
)
Array
(
[0] => XZY
)
Array
(
[0] => ABC
)
i have use some function array unique and convert it to json ... and not work
Upvotes: 0
Views: 62
Reputation: 1963
$input = array_map("unserialize", array_unique(array_map("serialize", $array)));
Upvotes: 0
Reputation: 499
Use array_unique($array)
function in order to remove duplicate value. It takes an input array and returns a new array without duplicate values.
Upvotes: 2
Reputation: 3714
You can use array_merge() first. Then on result do array_unique();
Upvotes: 0