views:

23

answers:

1

object, contains 'array1'.

$Obj -> array1 [12]; // works fine. 

however, dynamically generating that array name - you can't use square brackets...

$var = 'array1';

$Obj -> $var [ 12] ; // nothing. no error, but no result.

I had to do

$ar = $Obj -> $var ; // copy out array
$ar [12] ; // get value in array.

note:

$Obj -> $$var [ 12]; // fatal error, cannot access empty property
$Obj -> ($var) [12] ; // error, unexpected '[' or '('
A: 

This should work: $Obj->{$var}[12]

Tom Haigh
Wonderful! so, the curly brackets mean "evaluate" ? and this can be used in other contexts also i assume. Thanks!
inteblio