Jump to content

Combine two arrays


Recommended Posts

I want $a to be like:

$a[0] = '1'

$a[1] = '2'

$a[2] = '3'

$a[3] = '4'

I tried this:

Func _ArrayCombine($a1, $a2)
    Dim $a[UBound($a1) + UBound($a2)]
    For $i = 0 To UBound($a) - 1
        If $i < UBound($a1) Then
            $a[$i] = $a1[$i]
        Else
            $a[$i] = $a2[UBound($a2) - $i]
        EndIf
    Next
    Return $a
EndFunc   ;==>_ArrayCombine

Dim $a1[2]
$a1[0] = "1"
$a1[1] = "2"

Dim $a2[2]
$a2[0] = "3"
$a2[1] = "4"

$a = _ArrayCombine($a1, $a2)

For $i = 0 To UBound($a) - 1
    MsgBox(0, '', $a[$i])
Next

But it doesnt work well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...