Home > Back-end >  How to compare value in array with value in multidimensional arrays?
How to compare value in array with value in multidimensional arrays?

Time:03-04

It's my problem.

 $arr_1 = ["a", "b", "c"];
 $arr_2 = [
    [
      "word" => "g"
    ],
    [
      "word" => "a"
    ]
 ]

So i want check

if $arr_2[n]["word"] value same $arr_1, then return true

Thanks you for help !!

CodePudding user response:

this should basically be the contents of your function

foreach($arr_2 as $words){
    if(in_array($words['word'], $arr_1)
        return true;
}
  • Related