title: Fatal error: Cannot use object of type User as array
body: <p>The users on the application are logged in by their e-mail. This e-mail is in a session. With this session I try to get more information of that user to print out there (sur)names and the avatar. When I do it in my navbar he's doing it all well but on the page itself it gives the following error:  <strong>'Fatal error: Cannot use object of type User as array'</strong></p>
  
  <p>What am i doing wrong?</p>
  
  <p>PHP:</p>
  
  <pre><code>$user = new User();
  $email = $_SESSION['email'];
  $user-&gt;getUserInfoByEmail($email);
  var_dump($user['avatar']);
  </code></pre>
  
  <p>FUNCTION:</p>
  
  <pre><code>public function getUserInfoByEmail($email)
  {
      $db = new Db();
      $select = "SELECT * FROM tblusers WHERE email = '" . $_SESSION["email"] . "';";
      $result = $db-&gt;conn-&gt;query($select);
      return $data=$result-&gt;fetch_assoc();
  
  }
  </code></pre>