How do you combine variables to get it to echo a variable(s) from an array of variables. for instance I am trying something like:
$Chapter=$_GET[“Chapter”];
$Line=$_GET[“Line”];
$Echo="$" . $Chapter . “[” . $Line . “]”;
echo $Echo;
The results I am getting is just it displaying the variable I need instead of the value of the variable for instance it would display $Chapter1[1] instead of what I have assigned to that variable in the array. how can I fix this?
Hi there,
glad to help you but can you rephrase your question? can’t seem get your question right…
I have two inputs, Chapter and Line, and I need to combine them into one variable. $Chapter#[#]. so when I get the input of the two it will tell my script where in the arrays find the line it’s looking for.
I need to learn to preview before I post… it should be $Chapter#[ # ] but without the spaces
As I understand it, you want to preview the name of variable as well as its values before finally posting it. Try this:
[php]
[/php]
No… that is what I already have… all it does is displays “$Chapter1[1]” when I echo it, I want it to display the value of the variable $Chapter1[1]… also you have lines in there two times, I only need it once, it’s chapter 1 line 1.
Ok, so I kinda figured out what I was doing wrong, instead of trying to combine the variables into another variable, I should just do echo $Chapter[$Line]; now it is only displaying 1 character from the variable though instead of the whole thing… Uggghhhh! Any Ideas?