如何在声明为变量的函数内访问变量? [重复]

Possible Duplicate:
Is it possible to access outer local variable in PHP?
PHP closure scope problem

Given this PHP function:

function get_deals_by_type($records, $type) {
  $available = function($record) {
    if($record->mobile_type == $type) return $record;
  };
  return array_filter($records, $available);
}

... how can I access the passed in $type inside of the function declared in $available? As it stands right now, $type returns NULL for array_filter regardless of what value is passed in to get_deals_by_type().

not sure but:

function get_deals_by_type($records, $type) {
  $available = function($record) use ($type) {
    if($record->mobile_type == $type) return $record;
  };
  return array_filter($records, $available);
}

see http://www.php.net/manual/de/functions.anonymous.php (shopping cart example)