Page 1 of 1

Associative arrays

Posted: 26 Feb 2026 11:29
by altoclef
From the Scripting > Arrays section in the help:
If the index or key is invalid the variable is seen just as a bit of text:

Code: Select all

$a["pussy"] = "cat";
    echo "It is a $a['fussy']!"; //It is a $a['fussy']!
However, if the empty array is created first:

Code: Select all

$a = array(); 
    $a["pussy"] = "cat";
    echo "It is a $a['fussy']!"; //It is a cat!
Have I misunderstood something or is the output incorrect?

[EDIT: Forgot to add my XY version. I'm on 27.20.1000.)

Re: Associative arrays

Posted: 26 Feb 2026 12:48
by admin
$a = array(); makes it implicitly non-associative. All string indices are then converted to number 0 (zero). I agree that this is a bug and it should be fixed. Raise your voice now if you think otherwise.

Re: Associative arrays

Posted: 27 Feb 2026 14:37
by altoclef
Confirmed fixed in v27.20.1004.
Thank you. :tup: