I’m trying to make a general if for some variables that i have in my database. Let’s say that we have the next variables and values:
$var1 = "abc";
$var2 = "n/a";
$var3 = "das";
$var4 = "n/a";
My if statement must include all these variables, check which variables contain “n/a” and for every variable that contain “n/a” the script must make another variable $var21 = "Not Available". Is that possible?
I’d not use
variable variables, just due to personal preference. If you’re masochistic, you can certainly try.I’d create an extra hash instead.
This would remove the need for an if-statement as well. 🙂Then when you need the text for a particular key you can just type
Updated:
To set it to the original if there is no value in
$descriptions, do the following: