Use la variable global en la función anónima

$variable;

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

this is called closure;
UnderTaker