Jump to content

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


rdaniyal

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.

Thanks.

Raja
Link to comment
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:

[code]
function ynchar_to_yesnostring($param)
{
  switch($param)
  {
     case "y":
     case "Y": $out = "yes"; break;
     case "n":
     case "N": $out = "no"; break;
     default: $out = ""; break;
  }
  return $out;
}[/code]

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

echo ynchar_to_yesnostring($enum); //would print yes
[/code]

You might want to make the function name shorter though if you use it often.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.