The arraydifference( documentation says:
This function creates a new array from two existing arrays. The new array contains only items that are in the first array but not the second array.
Perhaps it would be more clear if it said “the new array contains only values that are in the first array but not the second array.” That is what is really going on. So it doesn’t matter if a value appears more than once. If the value is in both arrays, it won’t be included in the result, no matter how many duplicates there are. It’s worked this way for I think at least 15 years, and for me at least this function has been very useful.
Sorry, there’s not a simple function that does this. I think you’d have to roll your own with a loop. Or maybe it can be done with a complicated formula, which would be faster. The current arraydifference( function is implemented with a complicated formula, which I’ve listed below. Perhaps that will provide inspiration.
ignore(“”,cache(arraystrip(arrayfilter(cache(arraysort(arraydeduplicate(arraystrip(arrayone,cache(thesep,“thearraysepchar”)),thesep)+thesep+arraydeduplicate(arraystrip(arraytwo,thesep),thesep),thesep),“tempboth”),thesep,{?(import() = array(tempboth,seq()-1,thearraysepchar),import(),“”)}),thesep),“comboarray”))+?(comboarray=“”,arrayone,arraystrip(arrayfilter(arrayone,thesep,{?(arraycontains(comboarray,import(),thearraysepchar),“”,import())}),thesep))