Jump to content
Sign in to follow this  
Info

Combine two arrays

Recommended Posts

Info

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.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.