VBScript array_diff_assoc function

A VBScript equivalent of PHP’s array_diff_assoc

Function array_diff_assoc(ByVal mAry1,ByVal mAry2)

    Dim retAry
    set retAry = Server.CreateObject("Scripting.Dictionary")

    If Not isObject(mAry1) or Not isObject(mAry2) Then
        set array_diff_assoc = retAry : Exit Function
    End If

    Dim j,k
    For Each j in mAry1

        retAry.Add j, mAry1(j)

        For Each k In mAry2
            if j = k and mAry1(j) = mAry2(k) Then retAry.Remove k

    set array_diff_assoc = retAry

End Function

Please also note that php.vbs offers community built functions and goes by the McDonald’s Theory. We’ll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just:

Other PHP functions in the array extension