Check for string in a PHP multidimensional array

Asked

Viewed 45 times

1

I have the following array:

array => [
  "c2_unid" => array:2 [
    0 => {
      "tipologia": "Tipologia"
    }
    1 => {
      "c2_unid": "Tipo"
    }
  ]
  "c1_unid" => array:2 [
    0 => {
      "disponibilidade": "Disponibilidade"
    }
    1 => {
      "c1_unid": "Unidade"
    }
  ]
]

I need to check in the arrays with nomenclature "c1_unid, c2_unid..." always in the array of position 0(first) there is the word "availability".

OBS: the arrays with "unid" nomenclature are dynamic and can reach more or less arrays.

  • But what do you expect in return? You just want if in any two c*_unid have the word "availability", or you want to perform an action by finding these values, in short, what you want to do when finding this value?

  • I needed a return true or false comparing and the keys of this array with the keys of another, I got with the answer below and more examples I found. Thank you very much!

1 answer

2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.