I am having trouble getting the name of a dynamic key from a JSON string.
I am using PHP

This is a sample of the JSON

```
{
"_text": "this is a test",
"entities": {
    "dynamic_key": [
        {
            "confidence": 0.99,
            "value": "thi is the answer"
        }
    ]
},
"msg_id": "1234532123"
}

```

I am using foreach to go trough the json key and get the values 

```
foreach ($json as $obj) {
        $search_term = $obj->_text;
        $msg_id = $obj->msg_id;
    }

```

But I am not sure how to get the value of the "dynamic\_key" which changes every time, and because of that I also cannot get the values of "confidence and value" keys.

Any ideas on how to approach this?

**Followed @Dimi, solution.** This is what I ended up with

```
$data=json_decode($json,true);

foreach ($data['entities'] as $key=>$val)
{
echo "Entity: $key";

    foreach ($data['entities'] as $keys){
        $conf = $keys[0]['confidence'];
        $answer = $keys[0]['value'];
        echo "conf: $conf, answ: $answer";
    }
}

```