Laravel 5.4中不支持的操作数类型 [英] Unsupported operand types in laravel 5.4
本文介绍了Laravel 5.4中不支持的操作数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
收到错误页面 这是产生错误的代码块.如何处理此代码段,我需要它在laravel 5.4上工作,$ extras变量是一个数组.
Error page recieved This is the code block where the error originates. How do I handle this code snippet, I need it to work on laravel 5.4 the $extras variable is an array.
/**
* Map to configuration
*
* @param $keys
* @param $config_var
* @param $extras
* @return array
*/
private function map_to_config($keys, $config_var, $extras = [])
{
try {
$configArray =
array_map(function ($string) use ($keys, $extras) {
line 132 where the error is--> return array_combine($keys, explode(":", $string)) + $extras;
}, explode(",", $config_var));
return array_filter($configArray);
} catch (\Exception $e) {
return [];
}
}
}
推荐答案
array_combine 如果作为参数给出的数组中的值数量不同,则返回 FALSE .这可能是为什么您收到关于不受支持的操作数类型的错误的原因-您正在尝试将布尔值与数组结合在一起.
array_combine returns FALSE if number of values in arrays given as arguments is different. That's probably a reason why you're getting an error about unsupported operand types - you're trying to combine a boolean with an array.
这篇关于Laravel 5.4中不支持的操作数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文