The array is empty, but the underlying data set isn't empty.
A little terminology might help: given a string (say, ‘myarray’), then a ‘struct’ (my term) is the collection of all variables with that string as prefix: the myarrray struct might contain myarray_0, myarray_1, myarray_2_fighter, myarray_Tiax, etc., etc. The myarray array is a dictionary into some, but not necessarily all, of the myarray struct. Using ‘myarray_Tiax=1’ adds to the struct but not to the array; using ‘$myarray(“Tiax”)=1’, or the (ACTION_)DEFINE_ASSOCIATIVE_ARRAY command, adds to both. And if you (ACTION_)CLEAR_ARRAY myarray, you wipe the dictionary but leave the struct alone.
As to how you can clear array entries: you can't. You can clear the array (the dictionary) but not the underlying struct (short of CLEAR_MEMORY). On reflection I don't think that's a problem: this function works fine.
DEFINE_DIMORPHIC_FUNCTION array_contains
STR_VAR array=""//array
key=""
val=""
RET value
BEGIN
OUTER_SET value=0
ACTION_PHP_EACH "%array%" AS k1=>v1 BEGIN
ACTION_IF ("%key%" STRING_EQUAL "%k1%" || "%key%" STR_EQ "") && ("%val%" STRING_EQUAL "%v1%" || "%val%" STR_EQ "") BEGIN
OUTER_SET value=1
END
END
END