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 7650717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:19:29+00:00 2026-05-31T11:19:29+00:00

Use of || (or) I got so many values which I need to compare

  • 0

Use of || (or)

I got so many values which I need to compare with same variable, is there a better way to write more efficiently such as $city == -35 || -34 || -33 or even simpler so that I don’t have to repeat variable name since it’s the same variable only value keep changing.

<?php

if ($city == -35 || $city == -34 || $xcity == -33)
{
    $region = "noindex";
}

?>

Any suggestions?

  • 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-05-31T11:19:30+00:00Added an answer on May 31, 2026 at 11:19 am

    You might use in_array()

    if (in_array($city, array(-35, -34, -33))) {
      $region = "noindex";
    }
    

    Or if they are consecutive ( I suspec they aren’t and this is just an example)

    in_array($city, range(-35, -33))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to explain my problem: I got many customcontrols of same type on
I have a problem which has been torturing for many hours. I need to
I've got a TreeView , in which I use a HierarchicalDataTemplate . With this,
I've got some soapUI tests, that use groovy scripts to first insert some data
I got many, many files to be uploaded to the server, and I just
Im trying to better understand how the huffman decoder works. Ive got a code
I've got a little problemo. In my CodeIgniter Controller I'm loading the same view
I've got some entities which have decimal properties on them. These entities' properties are
I have just got a task in a new project which is implemented using
I have got a List<Problem> which I want to export to a column based

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.