I have function like this:
class Service {
function delete_user($username) {
...
$sessions = $this->config->sessions;
$this->config->sessions = array_filter($sessions, function($session) use ($this){
return $this->get_username($session->token) != $username;
});
}
}
but this don't work because you can't use $this
inside use
, 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?