title: How to use $this in closure in php
body: <p>I have function like this:</p>
  
  <pre><code>class Service {
      function delete_user($username) {   
          ...
          $sessions = $this-&gt;config-&gt;sessions;
          $this-&gt;config-&gt;sessions = array_filter($sessions, function($session) use ($this){
              return $this-&gt;get_username($session-&gt;token) != $username;
          });
      }
  }
  </code></pre>
  
  <p>but this don't work because you can't use <code>$this</code> inside <code>use</code>, is it possible to execute function which is member of class Service inside a callback? Or do I need to use for or foreach loop?</p>