A VBScript equivalent of PHP’s array_merge_recursive
Function array_merge_recursive(mAry1,mAry2)
Dim j
Dim retAry : set retAry = Server.CreateObject("Scripting.Dictionary")
If isObject( mAry1 ) Then
For Each j In mAry1
if Not retAry.Exists(j) then retAry.Add j, mAry1(j)
Next
ElseIf isArray( mAry1 ) Then
For j = 0 to uBound( mAry1 )
retAry.Add j, mAry1(j)
Next
End If
If isObject( mAry2 ) Then
For Each j In mAry2
If isObject( mAry2(j) ) Then
set retAry(j) = array_merge_recursive(retAry(j),mAry2(j))
Elseif retAry.Exists(j) then
retAry.Item(j) = array(retAry.Item(j) , mAry2(j))
Else
retAry.Add j, mAry2(j)
End If
Next
ElseIf isArray( mAry2 ) Then
For j = 0 to uBound( mAry2 )
if retAry.Exists(j) then
retAry.Item(j) = array(retAry.Item(j) , mAry2(j))
Else
retAry.Add j, mAry2(j)
End If
Next
End If
set array_merge_recursive = 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: