簡單的問題,但艱難的答案?我在類方法中有以下匿名函數:在匿名函數中調用匿名函數(初始)
$unnest_array = function($nested, $key) {
$unnested = array();
foreach ($nested as $value) {
$unnested[] = (object) $value[$key];
}
return $unnested;
};
在同一個類方法中,我有這個數組,我保存了匿名函數。即我使用內聯create_function()
創建了一個新的匿名函數,我想要使用已定義的匿名函數$unnest_array()
。可能嗎?
$this->_funcs = array(
'directors' => array(
'func' => create_function('$directors', 'return $unnest_array($directors, "director");'),
'args' => array('directors')
)
);
此刻我得到「Undefined variable:unnest_array」。幫幫我?
您可能想將其稱爲「關閉」並刪除所有內容。 – 2012-08-12 19:04:18
[php.net](http://php.net/manual/en/functions.anonymous.php)將其稱爲匿名函數以及閉包。爲什麼要刪除一切 – Viktor 2012-08-12 22:04:15
加1即使只是爲了開始部分:D – Bakaburg 2012-09-05 00:32:31