PHP - HOW TO Access a Global Associate Array Variable Inside a Function

To access a regular global variable in PHP you simply remove the dollar sign from the variable and surround the variable with $GLOBALS[''], so for example to access a variable declared outside a function $myVar, you would use $GLOBALS['myVar']. To do this with an associative array ...

Home Short:

to access a regular global variable in PHP you simply remove the $ from the variable and surround the variable with $GLOBALS[''], so for example to access a variable declared outside a function $myVar, you would use $GLOBALS['myVar']. To do this with an associative array ...

You can also modify the value of a global associate array variable like so:

$GLOBALS['myVar']['state'] = 'Nebraska';

S
H
A
R
E