VBScript array_fill function

A VBScript equivalent of PHP’s array_fill


Function array_fill(start_index, num, val)

    If Not isNumeric(num) or num < 1 then Exit Function

    Dim intCounter,ary()
    Dim i

    intCounter = start_index + num -1
    ReDim ary(intCounter)

    For i = start_index to intCounter
        ary(i) = val
    Next

    array_fill = ary

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