Jump to content

Simple question about variables


bytte

Recommended Posts

I have an array called "foo" that I want to echo to the screen.

However, the array name "foo" is dynamically generated. So I can't write this in my script:

echo $foo[0];

 

I first have to do some logic do get the variable name:

//$someOtherVar contents is the string "foo"
$varName = $someOtherVar;

 

If $varname is now containing the string "foo", then how can I get the contents of the array with the name "foo"? I can't do this, can I?

echo $varName[0];

 

I hope my question is clear.

 

 

Link to comment
https://forums.phpfreaks.com/topic/130417-simple-question-about-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.