Hello, I have a question regarding the scope of array variables. I have a small script which is split up between many files, and there are a few array variables I need to be global (persistent).
I have had no problems with normal variables, by declaring them global in each functions, nor with constant arrays:
my config.php file (included everywhere)contains a constant array which is declared as such:
$bingoletters=array("B","I","N","G","O");
and this array is available everywhere when declared as global in each function.
But I am unable to do the same for a variable array.
by declaring it in my config.php file as:
$variablearray=array();
it is reinitialized at each page reload-> no good: I need persistence.
I tried with static also, without success. I wasn't successful at passing the array in the URL either 🙂
The only solution I have found is to save the array to a file, and reload it everywhere I need it, definitely not an efficient way of doing business, my array "file" can be up to 10 Mb (it's a Bingo card generator, a 1000 cards is about 1 Mb). I am trying to not require a database to allow more flexibility.
Any ideas? thanks a lot!