Strict Standards: Only variables should be passed by reference in G:\xampp\htdocs\MyProject\ZendSkeletonApplication\module\Admission\src\Admission\Controller\AdmissionController.php on line 107
我的代码
$consoldatedCities='';
array_walk_recursive($StateCityHash, function($cityName,$cityId) use(&$consoldatedCities){$consoldatedCities[$cityId] = $cityName; }); // line 107
这是将多维数组转换为简单数组
但是代码按我的预期工作..任何人都可以告诉我如何解决这个问题
http://php.net/manual/en/language.references.pass.php 它说“函数调用上没有引用符号 - 仅在函数定义上。”尝试从函数调用代码中删除“&”,看看是否可以消除该消息。
---编辑---在这里查看此线程您可以尝试将回调函数保存到变量中,然后再将其传递给数组遍历函数:
$consoldatedCities=array();
$callbackFcn=
function($cityName,$cityId) use(&$consoldatedCities)
{
$consoldatedCities[$cityId] = $cityName;
};
array_walk_recursive($StateCityHash, $callbackFcn);