I have 2 arrays as given below. I want to check if all items of first array $arrayA
are available in $arrayB
against key fruit
. How I can do that?
<?php
$arrayA = ['apple', 'guava'];
$arrayB = [
['fruit' => 'apple','vegetables' => 'potato'],
['fruit' => 'guava','vegetables' => 'onion']
];
$containsSearch = count(array_intersect($arrayA, $arrayB)) == count($arrayA);
var_dump($containsSearch);
Above code returns error:
PHP Notice: Array to string conversion in /var/www/html/test/b.php on line 8