How to access arrays from $GLOBAL?
| From: | Richard Davey | Date: | Wed, 13 Mar 2002 16:01:55 +0000 |
| Subject: | How to access arrays from $GLOBAL? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-88359@lists.php.net to get a copy of this message | ||
Hi all,
I have a global array $mtxt that is created in my script.
I have a function from which I want to access a value from that array:
$mtxt[1] = "Test";
$text = $GLOBALS['mtxt[1]'];
Except that gives me the Warning "Undefined index";
I can use $GLOBALS['mtxt'] to access a global variable without an error,
just not a specific element of a global array.
Does anyone know the correct syntax for this?
I have tried:
$text = $GLOBALS["mtxt[1]"];
$text = $GLOBALS["{mtxt[1]}"];
But both fail too.
Cheers,
Richard
--
Fatal Design
http://www.fatal-design.com
Atari / DarkBASIC / Coding / Since 1995