Re: [PHP] How to access arrays from $GLOBAL?

2002-03-15 Thread bvr



Maybe it makes sense to you like this:

$mtxt = $GLOBALS['mtxt'];

$mtxt === $GLOBALS['mtxt']
$mtxt[1] === $GLOBALS['mtxt'][1]

bvr.

 hmm.. the '===' operator, now that's weird ;)

Because in my mind (which I know is totally wrong in this instance, I'm just
explaining for your benefit) using:

$GLOBALS['mtxt'][1];

is like saying give me element 1 of the globals array when I was thinking
but I want element 1 of the mtxt array which is why I tried the various
combinations of mtxt[1] _inside_ of the globals[].

Hope that explains a little.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Richard Davey

Hi all,

I have a global array $mtxt that is created in my script.
I have a function from which I want to access a value from that array:

$mtxt[1] = Test;
$text = $GLOBALS['mtxt[1]'];

Except that gives me the Warning Undefined index;

I can use $GLOBALS['mtxt'] to access a global variable without an error,
just not a specific element of a global array.
Does anyone know the correct syntax for this?

I have tried:

$text = $GLOBALS[mtxt[1]];
$text = $GLOBALS[{mtxt[1]}];

But both fail too.

Cheers,

Richard
--
Fatal Design
http://www.fatal-design.com
Atari / DarkBASIC / Coding / Since 1995



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Ford, Mike [LSS]

 -Original Message-
 From: Richard Davey [mailto:[EMAIL PROTECTED]]
 Sent: 13 March 2002 16:02
 
 I have a global array $mtxt that is created in my script.
 I have a function from which I want to access a value from that array:
 
 $mtxt[1] = Test;
 $text = $GLOBALS['mtxt[1]'];
 
 Except that gives me the Warning Undefined index;
 
 I can use $GLOBALS['mtxt'] to access a global variable 
 without an error,
 just not a specific element of a global array.
 Does anyone know the correct syntax for this?

$GLOBALS['mtxt'][1]

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Richard Davey

Mike Ford [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 $GLOBALS['mtxt'][1]

Fantastic :)

That's totally illogical but it works a treat.
PHP has some weird syntax rules sometimes!

Cheers,

Rich
--
Fatal Design
http://www.fatal-design.com
Atari / DarkBASIC / Coding / Since 1995



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Rasmus Lerdorf

I don't understand why you think it is illogical.  How else would you
dereference a multi-dimensional array?

On Wed, 13 Mar 2002, Richard Davey wrote:

 Mike Ford [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  $GLOBALS['mtxt'][1]

 Fantastic :)

 That's totally illogical but it works a treat.
 PHP has some weird syntax rules sometimes!

 Cheers,

 Rich
 --
 Fatal Design
 http://www.fatal-design.com
 Atari / DarkBASIC / Coding / Since 1995



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Andrey Hristov

IMO it is not weird. Think about $GLOBALS['mtxt'] as a pointer to array(it is not but 
this is a good example).
$GLOBALS is a hash list. So it has sub elements - zvals (internal _zend_value ). Every 
from these zvals can hold zvals. In C the
syntax is arFooBar[1][2], not arFooBar[[1][2]]

I am not nagging(not sure for the word) at you.


Best regards,
Andrey Hristov
- Original Message -
From: Richard Davey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, March 13, 2002 6:52 PM
Subject: Re: [PHP] How to access arrays from $GLOBAL?


 Mike Ford [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  $GLOBALS['mtxt'][1]

 Fantastic :)

 That's totally illogical but it works a treat.
 PHP has some weird syntax rules sometimes!

 Cheers,

 Rich
 --
 Fatal Design
 http://www.fatal-design.com
 Atari / DarkBASIC / Coding / Since 1995



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Hunter, Ray

Where is some good documentation on how $GLOBALS works and what is really
going on in the background?


Thank you,

Ray Hunter
Firmware Engineer

ENTERASYS NETWORKS


-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, March 13, 2002 9:53 AM
To: Richard Davey
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to access arrays from $GLOBAL?


I don't understand why you think it is illogical.  How else would you
dereference a multi-dimensional array?

On Wed, 13 Mar 2002, Richard Davey wrote:

 Mike Ford [EMAIL PROTECTED] wrote in message 
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED].
 ..
  $GLOBALS['mtxt'][1]

 Fantastic :)

 That's totally illogical but it works a treat.
 PHP has some weird syntax rules sometimes!

 Cheers,

 Rich
 --
 Fatal Design
 http://www.fatal-design.com
 Atari / DarkBASIC / Coding / Since 1995



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Andrey Hristov

Sources.

Andrey 

- Original Message - 
From: Hunter, Ray [EMAIL PROTECTED]
To: 'Rasmus Lerdorf' [EMAIL PROTECTED]; Richard Davey [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 13, 2002 6:59 PM
Subject: RE: [PHP] How to access arrays from $GLOBAL?


 Where is some good documentation on how $GLOBALS works and what is really
 going on in the background?
 
 
 Thank you,
 
 Ray Hunter
 Firmware Engineer
 
 ENTERASYS NETWORKS
 
 
 -Original Message-
 From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, March 13, 2002 9:53 AM
 To: Richard Davey
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] How to access arrays from $GLOBAL?
 
 
 I don't understand why you think it is illogical.  How else would you
 dereference a multi-dimensional array?
 
 On Wed, 13 Mar 2002, Richard Davey wrote:
 
  Mike Ford [EMAIL PROTECTED] wrote in message 
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED].
  ..
   $GLOBALS['mtxt'][1]
 
  Fantastic :)
 
  That's totally illogical but it works a treat.
  PHP has some weird syntax rules sometimes!
 
  Cheers,
 
  Rich
  --
  Fatal Design
  http://www.fatal-design.com
  Atari / DarkBASIC / Coding / Since 1995
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Richard Davey

Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I don't understand why you think it is illogical.  How else would you
 dereference a multi-dimensional array?

Because in my mind (which I know is totally wrong in this instance, I'm just
explaining for your benefit) using:

$GLOBALS['mtxt'][1];

is like saying give me element 1 of the globals array when I was thinking
but I want element 1 of the mtxt array which is why I tried the various
combinations of mtxt[1] _inside_ of the globals[].

Hope that explains a little.

Cheers,

Richard
--
Fatal Design
http://www.fatal-design.com
Atari / DarkBASIC / Coding / Since 1995




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Rasmus Lerdorf

I am not sure there is any.  $GLOBALS is simply an array that contains
individual references to each global variable.

For example:

  $a = 1;
  $GLOBALS['a'] = 2;
  echo $a;

gives you 2

The best documentation is probably the basic explanation of how references
work.  http://php.net/references

-Rasmus

On Wed, 13 Mar 2002, Hunter, Ray wrote:

 Where is some good documentation on how $GLOBALS works and what is really
 going on in the background?


 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, March 13, 2002 9:53 AM
 To: Richard Davey
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] How to access arrays from $GLOBAL?


 I don't understand why you think it is illogical.  How else would you
 dereference a multi-dimensional array?

 On Wed, 13 Mar 2002, Richard Davey wrote:

  Mike Ford [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED].
  ..
   $GLOBALS['mtxt'][1]
 
  Fantastic :)
 
  That's totally illogical but it works a treat.
  PHP has some weird syntax rules sometimes!
 
  Cheers,
 
  Rich
  --
  Fatal Design
  http://www.fatal-design.com
  Atari / DarkBASIC / Coding / Since 1995
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Andrey Hristov

to add that $GLOBALS has reference to itself but when used in non-function context. 
Try ?php var_dump($GLOBALS);? and ?php
function a(){ var_dump($GLOBALS); } a(); ?

Regards,
Andrey Hristov

- Original Message -
From: Rasmus Lerdorf [EMAIL PROTECTED]
To: Hunter, Ray [EMAIL PROTECTED]
Cc: Richard Davey [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, March 13, 2002 7:09 PM
Subject: RE: [PHP] How to access arrays from $GLOBAL?


 I am not sure there is any.  $GLOBALS is simply an array that contains
 individual references to each global variable.

 For example:

   $a = 1;
   $GLOBALS['a'] = 2;
   echo $a;

 gives you 2

 The best documentation is probably the basic explanation of how references
 work.  http://php.net/references

 -Rasmus

 On Wed, 13 Mar 2002, Hunter, Ray wrote:

  Where is some good documentation on how $GLOBALS works and what is really
  going on in the background?
 
 
  Thank you,
 
  Ray Hunter
  Firmware Engineer
 
  ENTERASYS NETWORKS
 
 
  -Original Message-
  From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, March 13, 2002 9:53 AM
  To: Richard Davey
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP] How to access arrays from $GLOBAL?
 
 
  I don't understand why you think it is illogical.  How else would you
  dereference a multi-dimensional array?
 
  On Wed, 13 Mar 2002, Richard Davey wrote:
 
   Mike Ford [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED].
   ..
$GLOBALS['mtxt'][1]
  
   Fantastic :)
  
   That's totally illogical but it works a treat.
   PHP has some weird syntax rules sometimes!
  
   Cheers,
  
   Rich
   --
   Fatal Design
   http://www.fatal-design.com
   Atari / DarkBASIC / Coding / Since 1995
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How to access arrays from $GLOBAL?

2002-03-13 Thread Ford, Mike [LSS]

 -Original Message-
 From: Richard Davey [mailto:[EMAIL PROTECTED]]
 Sent: 13 March 2002 17:12
 
 Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I don't understand why you think it is illogical.  How else 
 would you
  dereference a multi-dimensional array?
 
 Because in my mind (which I know is totally wrong in this 
 instance, I'm just
 explaining for your benefit) using:
 
 $GLOBALS['mtxt'][1];
 
 is like saying give me element 1 of the globals array when 
 I was thinking
 but I want element 1 of the mtxt array

But $GLOBALS['mtxt'] *is* the mtxt array -- so logically element 1 of it can only be 
$GLOBALS['mtxt'][1].

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php