Re: dynamically accessing arrays at variable indexes

From: Date: Sat, 10 Mar 2001 02:47:38 +0000
Subject: Re: dynamically accessing arrays at variable indexes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43280@lists.php.net to get a copy of this message
http://php.net/print_r -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: "Dale Robinson" <john_robinson@btinternet.com> Newsgroups: php.general Sent: Friday, March 09, 2001 2:04 PM Subject: [PHP] dynamically accessing arrays at variable indexes > Hi, > > I need to access array values at varying dimensions. > > What I want to do is something like this: > > $full_index = ["op"]["view"]; > > print ${"HTTP_GET_VARS" . $full_index}; > > but that doesnt work :( > > A messy solution would be: > > function return_array_value($index1, $index2) > { > if ($index2) { > return $HTTP_GET_VARS[$index1][$index2]; > } else { > return $HTTP_GET_VARS[$index1]; > } > } > > but this would mean I would have to continue adding 'if' clauses if I wanted > to access values more than one dimension deep. > > Is there a neat way of getting at array values dynamically? > > D. Robinson > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#43280) next »