Hi,
i am using a two dimensional array like this:
Dim $formfields[3][2] = [["element1", "data1"],["element2", "data2"],["elemnt0","data0"]]
there can be x elements.
My problem is that i need to have a certain element at the first position (the order of the other elements does not matter, only on certain element hast to be at position 1).
Dim $formfields[3][2] = [["element0", "data0"],["element1", "data1"],["elemnt2","data2"]]
I wanted to check if a certain element exist in formfields and if it exists, i remove it and re insert it at position 1. If it does not exist, i just want to add it at position 1.
I tried several things, but i could not get this done correctly, due to problems with the array dimensions after removing/adding...
Can anyone show me how to do it right?
thanks in adnvance,
Edit:
here is what already works:
Func _AddOrUpdateFieldIn2DArray($array, $fieldname, $data = "") $iIndex = _ArraySearch($array, $fieldname, 0, 0, 1, 2, 1, 0) If $iIndex <> -1 Then;the field exists If $array[$iIndex][1] = $data Then ;already up to date Else ;update $array[$iIndex][1] = $data EndIf Else ;add ReDim $array[UBound($array) + 1][2] $array[UBound($array) - 1][0] = $fieldname $array[UBound($array) - 1][1] = $data EndIf Return $array EndFunc
and would like to have something like this also: