PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fgomez
Forum Commoner
Posts: 61 Joined: Mon Sep 26, 2005 11:23 pm
Location: Washington, DC
Post
by fgomez » Wed Apr 18, 2007 9:24 am
Normally I do this:
Code: Select all
$foo = $_GET['foo'] ;
echo $some_array[$foo] ;
Is there a way to skip that step and do something like this:
I know this doesn't work, but I wonder if there is a syntax that does.
Thanks!
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Apr 18, 2007 9:27 am
fgomez wrote:
I know this doesn't work, but I wonder if there is a syntax that does.
This does work.
fgomez
Forum Commoner
Posts: 61 Joined: Mon Sep 26, 2005 11:23 pm
Location: Washington, DC
Post
by fgomez » Wed Apr 18, 2007 9:36 am
That's weird.... I'd tried that before and got a syntax error. I must have made an error somewhere else in the page and misinterpreted the message.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed Apr 18, 2007 10:45 am
My philosophy... try until you cannot possibly try anymore, then ask.
That type of syntax can be used to levels that are far deeper than one dimension. I wouldn't suggest it, but it can be done.