how to access global array (user defined)
Posted: Sun Jan 27, 2008 12:37 pm
Hi,
I wonder if someone can help me understand this. I can access global variable from inside the function but not a global array. How do I add value to my array then?
I wonder if someone can help me understand this. I can access global variable from inside the function but not a global array. How do I add value to my array then?
Code: Select all
<?
$attributes[] = ""; // a blank array
$optionCounter=0; // a global variable
function setOption($a){
global $optionCounter; //accessing global variable - works fine
global $attributes // accessing global array - doesn't work
//add attribute to attribute array
$attributes[] = $a; // this doesn't work either coz access to global array failed
//increment optionCounter by one
$optionCounter++; // works fine
}
//test time
setOption("Size");
?>