Checking if an array contains all elements of another array

后端 未结 6 641
滥情空心
滥情空心 2020-12-06 19:23

I\'m designing an electrical engineering application. However, i\'m stuck on this: I have the following array



        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 19:52

    You can try :

    $searchKeys = array();
    foreach ( $GroupOfEight as $key => $values ) {
        (count(array_intersect($values, $myStack)) == count($myStack)) and $searchKeys[] = $key;
    }
    
    #Output all keys it found same match
    var_dump($searchKeys);
    
    #OR Output Each Array it found a match
    foreach($searchKeys as $key)
    {
        var_dump($GroupOfEight[$key]);
    }
    

提交回复
热议问题