9
在以下代碼中,傳遞給wrap_map的回調函數無法在外部函數中看到參數,爲什麼? (詳見代碼註釋)php array_map回調參數範圍
public static function wrap_implode($ar, $wrap, $delim){
echo "wrap is $wrap"; //wrap is ok
$res = array_map(function($val){
echo "wrap is $wrap"; //wrap is not set here!
return $wrap. $val . $wrap;
}, $ar);
return implode($delim, $res);
}
冷卻使用關鍵字(函數),我學到了一些東西: ) – FMaz008 2011-12-06 19:51:13