0

Good Afternoon,

I have this line of code:

echo $sum;

Earlier in my page, I have set a variable to:

$wk="wk1";

What is the syntax to use the Variable $wk instead of spelling out wk1.

I want to be able to change $wk once and have it change throughout a number of pages.

Thanks
Chris

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Fbody
1

It's been a while since I worked with PHP, but I'm sure you can just put the variable directly in the braces.

echo $sum[$wk];

If you need the rest of the string that you have entered, change the single-quotes to double-quotes. PHP will resolve a variable that's contained within double-quotes.

echo $sum["PTS1011_$wk"];

Edited by Fbody: n/a

Votes + Comments
Thank you!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.