You can consider this as an example:
$color = array(
"blue"=> array("status"=>"my favorite colors"),
"green"=> array("status"=>"my favorite colors"),
"red"=> array("status"=>"NOT my favorite colors")
);
$favorite = array();
foreach($color as $key => $myfav) {
if(!in_array($myfav['status'], $favorite)) {
$favorite[$key] = $myfav['status'];
}
}
print_r($favorite);
Output:
Array
(
[blue] => my favorite colors
[red] => NOT my favorite colors
)
Put them first inside the array, then check if already exists, then it will just skip.
EDIT: If you want to get the keys (you want to keep them, because you both like blue and green) you can use this:
foreach($color as $key => $myfav) {
$exists = array_search($myfav['status'], $favorite);
if($exists === false) {
$favorite[$key] = $myfav['status'];
} else {
unset($favorite[$exists]);
$exists .= ', ' . $key;
$favorite[$exists] = $myfav['status'];
}
}
Output:
Array
(
[blue, green] => my favorite colors
[red] => NOT my favorite colors
)