Jump to content


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

  • Please log in to reply
1 reply to this topic

#1 rdaniyal

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 August 2006 - 01:40 PM

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.



#2 tox_yray

  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 August 2006 - 03:22 PM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users