Imar,
The global array is being defined in the mainline, but not populated. What happens if 
you set element 0 to some
value (to take up some storage space first) and then try the switched function calls?
When you say "Alas, this also emptied the array each time I went from one function to 
another via the switch
statement." do you mean that the array definition line is inside the same loop that 
causes the switch statement
to be revisited?
(it shouldn't be - put it right at the beginning of the 'mainline' and ensure that it 
is not re-executed (which
would indeed 'reset' the values))
Regards,
=dn



----- Original Message -----
From: "Imar de Vries" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 28 October 2001 21:49
Subject: Re: [PHP] switch-statement overrides use of global arrays?


> Henrik Hudson wrote:
>
> > I would think you would need to define $array_test outside in a "global"
> > environment rather then inside the function since I think/thought it will
> > just stay scoped in there and that  "global" was used to access variables
> > which weren't defined inside a functions scope and make it look outside.
> >
> > In other words
> >
> > //Define GLOBAL
> > $array_test = array();
> >
> > switch(){
> > BLAH
> > BLAH
> >
> > }
> >
> > function main() {
> > global $array_test;
> > BLAH
> > BLAH
> >
> > }
> >
> > function test_one(){
> > global $array_test;
> > BLAH
> > BLAH
> >
> > }
>
> Yes, the only way I could avoid errors that occurred when I tried to manipulate
> the array, was to add a $array_test = array(); a few lines before the switch
> statement. Alas, this also emptied the array each time I went from one function
> to another via the switch statement.
>
> I guess I am trying something that is just not possible (when I insist on using
> the switch statement)?
> --
> Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to