Jump to content


This topic is now archived and is closed to further replies.


Converting Enum 'Y','N' to Yes and No

Recommended Posts

Hi guys,

I have a large table with over 20 enums. The result shows Y and N for each column. How can I change the enum Y to yes and N to No?

Changing individually can be a bit of pain so if there is a way to change all that will be better. My knowledge is limited with php so kindly elaborate on solution.



Share this post

Link to post
Share on other sites
I am not sure wether this is what you want, but at the moment of printing the values, you could just do a switch that would echo either "yes" or "no" depending on the letter it received as a $case... You could even functionalize it for better readablility:

function ynchar_to_yesnostring($param)
     case "y":
     case "Y": $out = "yes"; break;
     case "n":
     case "N": $out = "no"; break;
     default: $out = ""; break;
  return $out;

An example use of this would be that:
$enum = "Y";

echo ynchar_to_yesnostring($enum); //would print yes

You might want to make the function name shorter though if you use it often.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.