I am in a confusing situation, I have an array where I want the duplicates removed. e.g
$arr = [
0 => array:25 [
"content" => "abc" //duplicate
]
1 => array:25 [
"content" => "def"
]
2 => array:1 [
"content" => "abc" //duplicate
]
]
Now, I use array filter like this trying to remove duplicate "abc"
$filtered = array_filter( $arr, function($item) use($arr)
{
foreach($arr as $item1)
{
return $item1['content'] !== $item['content']
}
}
This will give me the $filtered variable to be
[
0 => array:25 [
"content" => "def"
]
]
But, what I really want is
[
0 => array:25 [
"content" => "abc"
]
1 => array:25 [
"content" => "def"
]
]
i.e Removing one instance of duplicate not all.