2012-04-21 143 views

回答

0

如前所述here,PHP的模板的map-reduce是:

01 function map ($filename, $content) { 
02  foreach (explode('', $content) as $word) { 
03   collect($word, 1); 
04  } 
05 } 
06 
07 function reduce($word, $values) { 
08  $numWordCount = 0; 
09 
10  foreach ($values as $value) { 
11   $numWordCount += $value; 
12  } 
13 
14  collect($word, $numWordCount); 

現在,不能的$filename值是printed inside a php function