No, you misunderstand. The key is simply a string. Just as "print foo;" is wrong, $array[foo] is wrong (unless foo is a constant, of course). If you do "print '$variable';", it will print the literal string "$variable". It will not print the value of $variable. You should either use double quotes or no quotes.

Johnson, Kirk wrote:

I think you either want to use no quotes or double quotes, but not single
quotes. Double quotes will interpolate the variable, single quotes will not,
i.e. $key becomes a string literal rather than a variable. No quotes will
work, although the docs seem to indicate it is deprecated syntax. Not
everyone agrees that it is deprecated, though ;)

Kirk



$GLOBALS[$key] is incorrect and depricated AFAIK.
$GLOBALS['$key'] (with the single quotes) is the proper way to write these
types of associative arrays/hashs.






-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




Reply via email to