lundi 27 juin 2016

Is there a way to check if value in object is set without using foreach?

I have the following JSON object:

{
  "screen": 1,
  "parameters": {
    "title": "Fill in the form:",
    "values": [
      {
        "id": 13,
        "type": 2,
        "name": "A",
        "label": "Lorem ipsum",
        "value": 10
      },
      {
        "id": 14,
        "type": 2,
        "name": "B",
        "label": "Lorem ipsum",
        "value": 20
      }
    ]
  }
}

In the code I access the values using $screen = /*object*/; $screen->parameters->values.

Is there a fast way to check if the values of answer A and B are filled in? I tought something like this:

if(isset(A) && isset(B)) { ... }

For those who are interested, I use laravel 5, maybe there is a method for it?

It looks like I need an foreach, but I rather avoid those in this case...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire