#include<Array.au3>
Local $aTest[4] = ['banana=>1', 'berry=>3', 'apple=>5', 'apple=>two']
ConsoleWrite(StringFormat('In the basket %s: %s\r', 'banana', _AssocArray($aTest, 'banana')))
ConsoleWrite(StringFormat('In the basket %s: %s\r', 'berry', _AssocArray($aTest, 'berry')))
ConsoleWrite(StringFormat('In the basket %s: %s\r', 'apple', _AssocArray($aTest, 'apple')))
Func _AssocArray(ByRef $a_Array, $i_Key)
$o_Obj = ObjCreate("Scripting.Dictionary")
If @error Then SetError(1, 0, 0)
For $i = 0 To UBound($a_Array)-1
$a_Tmp = StringSplit($a_Array[$i], '=>', 1)
If Not $o_Obj.Exists($a_Tmp[1]) Then
$o_Obj.Add($a_Tmp[1], $a_Tmp[2])
Else
$o_Obj.Item($a_Tmp[1]) = $a_Tmp[2]
EndIf
Next
$v_Result = $o_Obj.Item($i_Key)
$i_UBound = $o_Obj.Count
$o_Obj = 0
Return SetError(0, $i_UBound, $v_Result)
EndFunc; ==>_AssocArray