About 20 years ago it occurred to me that software engineering was the Science of Successful Disappointments!
That short bright feeling of success followed by the darkening sky of yet another bug...
Right now I am enjoying that success brought about by your help!
The one star that seems constant however is the communal kindness of fellow coders. Thank you all for sharing your ever precious time, hard-won expertise, and clever ideas. Should any of you ever find yourself in Thailand, let me know. Coffee and dessert are on me 🙂
Apparently it is possible to create globals within functions. To complete the thread, I opted for the following (pseudo-code) solution which does work in my code:
<?php
first_function();
second_function() {
for ($count = 0; $count < $max; $count++) {
global $my_array; // make the variable global here
$my_array = array(); // set the variable to an array
third_function();
unset($my_array); // unset the variable here
}
}
third_function() {
global $my_array; // declare the variable as global here
//...fill my global array with stuff...
}
?>
While I agree with the view that using globals is a dangerous thing, I have three arrays which are used almost everywhere and changed in many places. Hence the globals. Fortunately I am a strong code documenter (from years of repeated experience with "what in the world was I thinking when I wrote this?") so array changes are clearly and explicitly stated.
Thank you again everyone! May your coding skies be bright and clear and path behind you littered with the desiccating corpses of vanquished bugs.
alexander