# Arrays...

## Recommended Posts

i have \$array_a :-

\$array_a[1] = a

\$array_a[2] = b

\$array_a[3] = c

\$array_a[4] = d

\$array_a[5] = e

and \$array_b :

\$array_b[1] = b

\$array_b[2] = d

\$array_b[3] = e

i want to exctract \$array_b FROM \$array_a

so the results will be :-

\$array_a[1] = a

\$array_a[2] = c

Hope this makes sense, thanks

##### Share on other sites

How did you get the results? Makes no sense to me...

What goes around comes around... Payback's a bitch.

##### Share on other sites

EDIT: i want to DELETE \$array_b FROM \$array_a

##### Share on other sites

```#include <Array.au3>

Dim \$array_a[5]
\$array_a[0] = "a"
\$array_a[1] = "b"
\$array_a[2] = "c"
\$array_a[3] = "d"
\$array_a[4] = "e"

Dim \$array_b[3]
\$array_b[0] = "b"
\$array_b[1] = "d"
\$array_b[2] = "e"

Dim \$array_c = _ArrayExtract(\$array_a, \$array_B)
_ArrayDisplay(\$array_c)

Func _ArrayExtract(\$Array1, \$Array2)
Dim \$Array3[1], \$Found
For \$i = 0 To UBound(\$Array1)-1
\$Found = False
For \$j = 0 To UBound(\$Array2)-1
If \$Array1[\$i] == \$Array2[\$j] Then
\$Found = True
EndIf
Next
If Not \$Found Then
ReDim \$Array3[UBound(\$Array3)+1]
\$Array3[0] += 1
\$Array3[UBound(\$Array3)-1] = \$Array1[\$i]
EndIf
Next
Return \$Array3
EndFunc```

Couldn't think of a better name for it, but it does what you want. It returns arrays like StringSplit() does, [0] element is the count of the rest of the items.

##### Share on other sites

thanks i will try this in my script

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...