0

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 !!

1
  • Use array_diff(); to compare $result = array_diff($a1,$a2); print_r($result); Commented Mar 3, 2022 at 9:40

1 Answer 1

1

this should basically be the contents of your function

foreach($arr_2 as $words){
    if(in_array($words['word'], $arr_1)
        return true;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank youuuu !! It's simple, the first time i tried array_search($words, array_column($arr_2, "word")) in for loop, But your solution is very nice, thanks you again !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.