title: PHP function not work properly
body: <p>I'm creating simple function with if condition to grand access to user:</p>
  
  <p>The following code is working fine.</p>
  
  <pre class="lang-php prettyprint-override"><code>$_SESSION['role'] = 3
  
  if($_SESSION['role'] == 1 || $_SESSION['role'] == 2){
      echo "Access Granted";
  }
  else
  {
      echo "Access Denied";
  }
  </code></pre>
  
  <p>The above code works  for me but not when I convert this into function like code below:</p>
  
  <pre class="lang-php prettyprint-override"><code>function access($allowed_users) {
  
      foreach ($allowed_users as $key =&gt; $value) {
              $user .= $_SESSION['role'] ." == ".$value." || ";  // Here I'm generating statement to use in If condition
      }
  
      $user = substr(trim($user), 0, -3);
  
      if($user){
          echo "Access Granted";
      }
      else
      {
          echo "Access Denied";
      }
  }
  
  access(array('1', '2'));
  </code></pre>
  
  <p>This does not work and always shows <code>Access Granted</code> when it should show <code>Access Denied</code> because in <code>$_SESSION['role']</code> value is 3.</p>