<?php
/* function myfunction($value,$key){
echo "The key $key has the value $value<br />";
}
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
array_walk($a,"myfunction");
The key a has the value Cat
The key b has the value Dog
The key c has the value Horse
array_walk($a,myfunction);
*/
//例四:在匿名函数中改变上下文的变量
function getMoney() {
$rmb = 1;
$func = function() use ( &$rmb ) {
echo $rmb . "<br/>";
//把$rmb的值加1
$rmb++;
};
$func();
echo $rmb;
}
getMoney();
//输出:
//1
//2
?>