php - Optimised function layout -


i trying figure out optimized way layout function.

the function has 3 variables, 2 of required.

currently, using conditionals first check round_id, inside round_id conditional, check type, inside if category_id exists (which optional).

does best way run little conditions possible?

 function count() {      var type = *post*; // required     var category_id = *post*; // optional     var round_id = *post*; // required      if ( round_id == "pre" ) {          if ( type == "adult" ) {              if ( category_id ) {              } else {              }          } elseif ( type == "youth" ) {              if ( category_id ) {              } else {              }          }      } elseif ( round_id == "1" ) {          if ( type == "adult" ) {              if ( category_id ) {              } else {              }          } elseif ( type == "youth" ) {              if ( category_id ) {              } else {              }          }      } elseif ( round_id == "2" ) {          if ( type == "adult" ) {              if ( category_id ) {              } else {              }          } elseif ( type == "youth" ) {              if ( category_id ) {              } else {              }          }      } elseif ( round_id == "3" ) {          if ( type == "adult" ) {              if ( category_id ) {              } else {              }          } elseif ( type == "youth" ) {              if ( category_id ) {              } else {              }          }      } else {          error      }  } 


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -