I have to following problem to solve:

This is my JSON:

```
{
    "colors": [{
            "color": "red",
            "value": "#f00"
        },
        {
            "color": "green",
            "value": "#0f0"
        },
        {
            "color": "blue",
            "value": "#00f"
        },
        {
            "color": "magenta",
            "value": "#0ff"
        },
        {
            "color": "magenta",
            "value": "#f0f"
        },
        {
            "color": "black",
            "value": "#ff0"
        },
        {
            "color": "black",
            "value": "#000"
        }
    ]
}

```

Now I have to receive all the objects where "color" is "magenta" and "black" and remove all the other objects. I only need objects containing "magenta" and "black".

I already tried this one:

```
$my_var = json_decode($json, true);
unset($my_var["magenta"]);
$json = json_encode($my_var);

```

But this can only remove one value, I need just the specified ones and none more.

The values for "magenta" and "black" are variable so they can differ in my application and can also be "blue" and "brown"
Can anyone help?