Jump to content

if($any_variable == '0'){$any_variable = "No";}


tekrscom

Recommended Posts

I was wondering, if you have several instances in which you use the same method of conversion for all variables from your database to your code, is there a way to effect them all, i.e.;

if($any_variable == '0'){$any_variable = "No";}
if($any_variable == '1'){$any_variable = "Yes";}

or

if($any_variable == '0'){$any_variable = "Pending";}
if($any_variable == '1'){$any_variable = "Closed";}

or

if($any_variable == '0'){$any_variable = "";} // Was also curious about this, is there a better way, instead of just using empty quotes, like some way to destroy the variable so it doesn't show anything?
if($any_variable == '1'){$any_variable = "Here is whatever";}

 

Its just that when you have to repeat this several times, for several different variables, it seems to make for alot of extra strung around code.

Link to comment
Share on other sites

ohya... also with...

 

if($any_variable == '0'){$any_variable = "No";}
if($any_variable == '1'){$any_variable = "Yes";}

 

you prolly want to code it this way... its alot faster ;-)...

 

switch($any_variable){
case "0":
  $any_variable="No";
break;
case "1":
  $any_variable="Yes";
break;
}

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.