A VBScript equivalent of PHP’s array_udiff_assoc
Function array_udiff_assoc(ByVal mAry1,ByVal mAry2, data_compare_func)
Dim arr_udif
set arr_udif = Server.CreateObject("Scripting.Dictionary")
If Not isObject(mAry1) then
set array_diff_uassoc = arr_udif
Exit Function
End If
Dim key,found
For Each key In mAry1
arr_udif.Add key, mAry1(key)
Next
If Not isObject(mAry2) Then Exit Function
For Each key In mAry2
If arr_udif.Exists( key ) Then
execute("found = " & data_compare_func & "(arr_udif(key), mAry2(key))")
If found = 0 Then
If arr_udif.Exists( key ) Then arr_udif.Remove key
ElseIf found < 0 Then
If isObject(mAry2(key)) Then
set arr_udif.Item( key ) = mAry2(key)
Else
arr_udif.Item( key ) = mAry2(key)
End If
End if
End If
Next
set array_udiff_assoc = arr_udif
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: