0

I have decoded a JSON message using a PHP script. I would like to check if one of the parameters (which is a blank array i.e. array()) is blank but I cannot find the value to check it against in an if statement.

To clarify what I am referring to, here is an example in JSON format:

"contexts": [],
"metadata": {
  "intentId": "8c7c5399-7eba-41ea-bda7-42075813a922",
  "webhookUsed": "true",
  "webhookForSlotFillingUsed": "false",
  "isFallbackIntent": "false",
  "intentName": "broom1.off.time"
}

It is the "contexts": [] value I would like to check against. In my PHP script I have the following code to do so:

if ($update["contexts"] == array()) {
    // do_something_here
}

N.B. $update has used the json_decode method to get the values of the JSON file. My question is, what is the value of that contexts paramenter?

Thanks.

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34

0 Answers0