Use variável global na função anônima

$variable;

functionName($someArgument, function() use(&$variable) {
  $variable = "something";
});

this is called closure;
UnderTaker