Test if one array is a subset of another

前端 未结 6 1298
庸人自扰
庸人自扰 2021-02-13 05:59

How can I determine if one array is a subset of another (all elements in the first are present in the second)?

 $s1 = \"string1>string2>string3>string4&         


        
6条回答
  •  醉梦人生
    2021-02-13 06:54

    I would create an associated array of the larger array, then iterate through the smaller array, looking for a non collision, if you find one, return false.

    function isSubset($arr1,$arr2){
        $map = Array();
        for ($i=0;$i

提交回复
热议问题