Gunakan variabel global dalam fungsi anonim

$variable;

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

this is called closure;
UnderTaker