title: Function returns true but if statement says otherwise
body: <p>I need someone with fresh eyes. I have a function that is checking to see if they have access to that topic, or section in my discussion board. This is the problem. I don't know if i'm typing something incorrectly.</p>
  
  <p>The function is returning 
  bool(true) and Granted (For Debugging)</p>
  
  <p>My if statement is echoing out that I don't have permission.</p>
  
  <pre><code>public function hasPermission($key) {
      $group = $this-&gt;_db-&gt;query("SELECT * FROM `group` WHERE `id` = ?", array($key));
      if ($group-&gt;count()){
          if ($key === 1) {
              return true;
          } else {
              $permissions = json_decode($group-&gt;first()-&gt;permissions, true);
              switch ($key) {
                  case 2:
                      $string = 'member';
                      break;
                  case 3:
                      $string = 'admin';
                      break;
              }
              print_r($string);
              if ($permissions[$string] === 1) {
                  if ($this-&gt;_user-&gt;hasPermission($string)){
                      print('Granted');
                      return true;
                  }
                  return false;
              }
              return false;
          }
  
      }
      return false;
  }
  </code></pre>
  
  <p>This is the the part that I don't understand. I know that you can call a function inside and if statement and it will continue if the function is true.</p>
  
  <pre><code>if (true) {
     //do this
  } else {
     //do this
  }
  </code></pre>
  
  <p>Right?</p>
  
  <p>Well my function is returning true but my if statement is not executing the correct block of code.</p>
  
  <pre><code>if (isset($_GET['id'])) {
      $id = $_GET['id'];
  
      $forum-&gt;topics($id);
      $topics = $forum-&gt;results();
  
      $permission = $forum-&gt;first();
      if (!empty($topics)) {
          foreach ($topics as $topic) {
              $list .= '&lt;tr&gt;';
              $list .= '&lt;td&gt;&lt;a href="topic.php?id=' . $topic-&gt;id . '"&gt;' . $topic-&gt;thread_title .'&lt;/a&gt;&lt;/td&gt;';
              $list .= '&lt;td&gt;Mr_Nasty_Time405&lt;/td&gt;';
              $list .= '&lt;td&gt;25&lt;/td&gt;';
              $list .= '&lt;td&gt;400&lt;/td&gt;';
              $list .= '&lt;/tr&gt;';
          }
      } else {
          $list .= '&lt;tr&gt;';
          $list .= '&lt;td&gt;There are no Sections under this category would you like to create one?';
          $list .= '&lt;/tr&gt;';
      }
      if($forum-&gt;hasPermission($permission-&gt;permissions)) {
      $error = "Granted";
      } else {$error = "You don't have permission";}
  } else {Redirect::to('404');}?&gt;
  </code></pre>