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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -