A VBScript equivalent of PHP’s array_intersect
Function array_intersect(mAry1,mAry2)
Dim key
Dim output : set output = Server.CreateObject("Scripting.Dictionary")
If isArray(mAry1) Then
For key = 0 to uBound(mAry1)
If len(array_search(mAry1(key),mAry2,false)) > 0 Then
output.Add key, mAry1(key)
End If
Next
ElseIf isObject(mAry1) Then
For Each key In mAry1
If len(array_search(mAry1(key),mAry2,false)) > 0 Then
output.Add key, mAry1(key)
End If
Next
End If
set array_intersect = output
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: