PHP Multidimensional Associative Array question?

  • Thread starter Thread starter redsox0077
  • Start date Start date
R

redsox0077

Guest
I have a question about multidimensional associative arrays in PHP.

I have a variable called $year = "2008",
and an array: $2008 = array(
"name1"=>array
( first=>"John", last=>"Smith")
);

When I use the echo statement:
echo $2008['name1'][first] ;
it outputs "John" correctly.

However, when I refer to the array using the variable $year, such as:
echo $$year['name1'][first] ;
I get the error: Fatal error: Cannot use string offset as an array in...


I'm no php expert -- anybody have any ideas?
 
Back
Top