• JeffSydor

    (@jeffsydor)


    I need to add to an existing block of code to specify which CSS a page uses.

    I want to basically say:

    If using THIS PAGE, then use THIS CODE for your css
    else, if using THAT PAGE, then use THAT CODE for your css
    else, if using NEITHER PAGE, then use SOME OTHER CODE for your css.

    So my code looks something like this (Note, $site_view is defined earlier in the header):

    if($site_view==’first’) {$site=array( big long array );}
    elseif($site_view==’second’) {$site=array( big long array );}
    elseif($site_view==’third’) {$site=array( big long array );}

    Now I want to essentially add this but I’m not sure if the statement syntax is correct. Should i use the commas or something else to separate them?:

    elseif($site_view != ‘first’, ‘second’, ‘third’) {$site=array( big long array );}

    I know it’s messy, but due to how the site is built, this is the easier alternative over developing a ‘fourth’ for $site_view since this all defines what the url is.

    Thanks!

Viewing 1 replies (of 1 total)
  • linux4me2

    (@linux4me2)

    If I’m understanding you correctly, what you’d use would be if…elseif…else something like this:

    if ($site_view == 'first') {
      $site = array();
    } elseif ($site_view == 'second') {
      $site = array();
    } else {
      $site = array();
    }

    However, a switch statement is faster than an if…elseif…else:

    switch ($site_view) {
      case 'first':
        $site = array();
      break;
      case 'second':
        $site = array();
      break;
      default:
        $site = array();
    }

Viewing 1 replies (of 1 total)
  • The topic ‘How do I properly state this comparison?’ is closed to new replies.