RE: [PHP] 3 dimensional array

From: Date: Mon, 31 Jul 2000 18:31:17 +0000
Subject: RE: [PHP] 3 dimensional array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-9223@lists.php.net to get a copy of this message
> I'm currently coding a small utility function, and in it i want a 3 > dimentional associative array. > Is it possible at all? > > For a 2-dim array the syntax is trivial: Array( "foo" => > "bar", "fuzzy" => > "bear" ); From everything I've learnt regarding arrays, that baby is one-dimensional, and could be accessed like this: echo $array['foo']; // Output: bar echo $array['fuzzy']; // Output: bear A two dimensional could look like this: $array = array('foo' => array('bar' => 'stuff')); and could be accessed like this: echo $array['foo']['bar']; // Output: stuff So your three dimensional doobry could be done like so: $array = array('foo' => array('bar' => array('fuzzy' => 'bear'))); and could be accessed like so: echo $array['foo']['bar']['fuzzy']; // Output: bear

« previous php.general (#9223) next »