I want to tell my function which variable to call based on the day of the week. The day of the week is stored in $ s_day, and the variables I want to call vary depending on what day it is on.
eg.
I saved the line "Welcome to the week" in $ d_monday_text1. Instead of creating a set of 7 conditional statements (for example, if date = monday echo $ foo, else if date = tuesday echo $ bar ...), can I change the name of the variable called in the function by combining the variable name?
$s_day = date("l"); $text1 = '$d_'.$s_day.'_text1';
I hope this evaluates to $ d_monday_text1, which, as mentioned above, has a value of "Welcome for a week." So later I would like to use:
echo $text1;
To get the final result = Welcome for a week.
I looked at the variable variables that might be here, but I'm struggling with the syntax. I can make his echo concatenate the name, but I cannot figure out how to get that name.
source share