Simple PHP. Try to get rid of nested if's
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4106382/compare-multiple-values-in-php">Compare multiple values in PHP</a>  </p>
</blockquote>



<p>Will someone help me to find a better way of writing this, please. I feel as if there has to be something better than nested ifs. I have tried searching, but I don't know what I am looking for.</p>

<p>The code says that if the session variable "auth" is not exactly equal to 0, 1, 2, or 3 then redirect to the login page.</p>

<pre><code>if($_SESSION['auth']!=0){
   if($_SESSION['auth']!=1){
      if($_SESSION['auth']!=2){
         if($_SESSION['auth']!=3){
            header("location:login.php");
         }
      }
   }
}
</code></pre>

<p>My initial thought was to do something like this.</p>

<pre><code>if($_SESSION['auth']&lt;=0 || $_SESSION['auth']&gt;=3){
   header("location:login.php");
}
</code></pre>

<p>But that doesn't account for fractions of the integer value. Which I only want to allow integer values. My next thought was this.</p>

<pre><code>if($_SESSION['auth']!=0 &amp;&amp; $_SESSION['auth']!=1 &amp;&amp; $_SESSION['auth']!=2 &amp;&amp; $_SESSION['auth']!=3){
   header("location:login.php")
}
</code></pre>

<p>But this way is not much different than all the nested ifs. Let me know if I am just attempting to fix something that isn't broken. Thank you in advance. A link to the relevant topic (PHP manual preferably) is all I'm looking for, not the solution.</p>
