[英]PHP Lambda function
Hey guys I messed up my Lambda somehow and it seems like my anonymous function isn't getting the variables from above, 大家好,我以某种方式弄乱了Lambda,似乎我的匿名函数没有从上面获取变量,
Some of the vars going in are 一些进入的var
print_r($cacheTypes);
print_r($servers);
Array
(
[concreter] => on
[config] => on
)
Array
(
[0] => dev-www.domain.com
)
the function is 功能是
$urls = array_walk($servers,
create_function('&$n',
'$n = "http://{$server}/".($vcpParam
? "flush-file-cache"
: "flushFileCache.php"
)."?tags=".implode("-", array_keys($cacheTypes));'
)
);
errors are 错误是
Warning: array_keys() expects parameter 1 to be array, null given
Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
Help greatly appreciated. 帮助极大的赞赏。 I'm positive it is not recognizing the variables I'm inputing, but I'm not sure why
我很肯定它无法识别我输入的变量,但是我不确定为什么
You can use 您可以使用
$urls = array_map(function ($var) use($cacheTypes, $vcpParam) {
return "http://{$var}/" . ($vcpParam ? "flush-file-cache" : "flushFileCache.php") . "?tags=" . implode("-", array_keys($cacheTypes));
}, $servers);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.