VBScript array_combine function

A VBScript equivalent of PHP’s array_combine

Function array_combine(keys,values)

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

    If uBound(keys) <> uBound(values) Then
        set array_combine = obj
        Exit Function
    End If

    Dim i
    For i = 0 to uBound(keys)
        If obj.Exists( keys(i) ) Then
            obj.Item( keys(i) ) = values(i)
            obj.Add keys(i) , values(i)
        End If

    set array_combine = obj

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