Hi all!
I’m trying to work on a little project here and I have to verify a few variables to change their initial value (“Y” or “N”) to “Actif” or “Inactif” (aka “enabled” / “disabled” in English) depending on the initial value to echo them later on.
Since I have many of them I wanted to create a function that would help me doing this whole thing dynamically.
Right now it goes like this for each of them:
[php]if ($cfu == “Y”) $cfu = “Actif”;
if ($cfu == “N”) $cfu = “Inactif”;[/php]
I have over 10 variables that are being verified like that for now but it will grow bigger.
So what I’ve tried is to create a function (very sloppy results hehe):
[php]
function yesNo($var) {
echo “$var”;
}
yesNo($cfu);
echo result is : Y
OR
function yesNo($var) {
echo “$var”;
}
yesNo(cfu);
echo result is: cfu
[/php]
Problem is that when the function is called, it replaces $cfu by it’s value, so $var returns the value of the $cfu variable (currently Y or N), not the variable name. I can’t seem to find a way to get the variable name passed through. If only I could “ln -s” those 2 variables hehe.
I’ve tried going yesNo(cfu) but then $var returns “cfu” only, and I can’t convert that so I can use it as a variable. Is there a way to do what I need to do?
Thanks for your help
Francois