A VBScript equivalent of PHP’s array_push
Function array_push(ByRef mAry, ByVal mVal)
Dim intCounter
Dim intElementCount
If IsArray(mAry) Then
If IsArray(mVal) Then
intElementCount = UBound(mAry)
ReDim Preserve mAry(intElementCount + UBound(mVal) + 1)
For intCounter = 0 to UBound(mVal)
mAry(intElementCount + intCounter + 1) = mVal(intCounter)
Next
Else
ReDim Preserve mAry(UBound(mAry) + 1)
mAry(UBound(mAry)) = mVal
End If
Else
If IsArray(mVal) Then
mAry = mVal
Else
mAry = Array(mVal)
End If
End If
array_push = UBound(mAry)
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: