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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -