php - Closure with confusing usort -
i trying rewrite co-developers script , ran across little gem, life of me cannot understand does, less how refactor it. explain me does, , if interpretation of code correct?
the original code:
$f = "return (${$v[0]}['{$k}'] - ${$v[1]}['{$k}']);"; usort($results, create_function('$a,$b',$f)); my attempt , rewriting closure:
$f = function ($k,$v) {     return ($v[0][$k] - $v[1][$k]); };  usort($results, $f($k, $v)); edit
for clarity, $k random string, , $v array of either ['a','b'] or array of ['b','a']
i'm lost on attempt was, maybe this?
usort($results, function () use ($k,$v)  {     return ($v[0][$k] - $v[1][$k]); }); 
you have this
$f = function ($k,$v) {     return ($v[0][$k] - $v[1][$k]); };  usort($results, $f);