Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:54:59+00:00 2026-06-11T01:54:59+00:00

I found this post: Switch case with three parameters? and I was considering using

  • 0

I found this post: Switch case with three parameters? and I was considering using switch case passing multiple parameters like this:

switch (array($var1, $var2, $var3)) {
case array(true, false, false):
    echo "hello";
    break;
}

There seems to be some question as to whether this is the most efficient way of doing this. The mood seems to be that an if conditional is more appropriate. But, when I look at the conditional I’m writing, I’m not sure? For example this feels messy (note that I’ve removed about 6 other conditionals to keep from boring you):

if ( 
  csz == "google" || 
  csz == "bing" || 
  csz == "yahoo" || 
  csz == "dogpile" || 
  csz == "millionshort" && 
  cs == '' ) { 
    $("li.phone").replaceWith('<li class="phone">' + phoneNaturalSearch + '</li>');
}
else if ( 
  csz == "facebook" && 
  cs == '' ) { 
    $("li.phone").replaceWith('<li class="phone">' + phoneFacebook + '</li>');
}
else if ( 
  csz == "google-plus" || 
  csz == "plus" ) { 
    $("li.phone").replaceWith('<li class="phone">' + phoneGooglePlus + '</li>');
}
// Snipped out other conditionals
else { 
    $("li.phone").replaceWith('<li class="phone">' + phoneDefault + '</li>');
}

Would switch with multiple parameters be more efficient here, or would I experience a performance hit? I guess I should write the code and see if it’s actually less messy, but I thought I’d bounce it off of the gurus first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:55:01+00:00Added an answer on June 11, 2026 at 1:55 am

    I feel if you have these many conditions I prefer to use switch statements which makes your code cleaner and easier to understand..
    You can omit the break’s for the conditions that fall for this particular category…

    var phoneType= '';
    
    switch(csz){ 
      case "google" : 
      case  "bing" : 
      case "yahoo" :
      case "dogpile"  : 
      case "millionshort" : 
        if (cs==''){ 
            phoneType = phoneNaturalSearch ;
            break;
        }
        else {
            goto case "facebook";
        }
      case "facebook" :
        if (cs==''){ 
            phoneType = phoneFacebook  ;
            break;
        }
        else {
            goto case "google-plus";
        }
      case "google-plus" :
      case "plus"  : 
        phoneType = phoneGooglePlus ;
        break;
      default : 
        phoneType = phoneDefault  ;
        break;
    }
    
    $("li.phone").replaceWith('<li class="phone">' + phoneType + '</li>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this post that shows how to pass multiple check box selections to
like in this post here by exemple I have found this blog but in
I found this post: Python: finding an element in an array and it's about
I found This Post and it looks like what I was needing for an
I'm using MGTwitterEngine. I've found this post where shows a modification to the current
I found this post useful and important to share, so if anybody has problems
I found this post: What's the Best Way to Shuffle an NSMutableArray? And as
I found this post on Crystal Reports Cutting Off Text in PDF , but
I recently found this post . It basically says that Eclipse has a modified
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.