我无法弄清楚为什么这不起作用$existingKeywordLookup
。
$existingKeywords = $sharedSet->negativeKeywords;
Yii::error("There are ".count($existingKeywords)." negative keywords.");
$existingKeywordLookup = array(); // this is a lookup table to index the objects by the keyword attribute
Yii::error("There are ".count($existingKeywordLookup)." existing keyword lookups.");
array_walk($existingKeywords, function ($v) use ($existingKeywordLookup) { $existingKeywordLookup[$v->keyword] = $v; }); // create lookup table
Yii::error("There are ".count($existingKeywordLookup)." existing keyword lookups.");
日志
2015-12-15 22:30:53 [::1][1][eai6tdgr5fjlimpfdk27taloa4][error][application] There are 15 negative keywords.
2015-12-15 22:30:53 [::1][1][eai6tdgr5fjlimpfdk27taloa4][error][application] There are 0 existing keyword lookups.
2015-12-15 22:30:53 [::1][1][eai6tdgr5fjlimpfdk27taloa4][error][application] There are 0 existing keyword lookups.
答案 0 :(得分:0)
我必须使用&
作为use
子句。
array_walk($existingKeywords, function ($v) use (&$existingKeywordLookup) ...