【发布时间】:2017-05-18 04:34:18
【问题描述】:
我想将所有空字符串转换为空字符串,我使用了array_walk_recursive,但我没有得到我想要的,请帮我弄清楚我在这里做错了什么。
protected function setData($key, $value)
{
$this->data[$key] = $value;
array_walk_recursive($this->data, function (&$item, $key) {
$item = null === $item ? '' : $item;
});
return $this->data;
}
【问题讨论】:
-
试试
$item = !is_null($item) ? $item : ''; -
也不行..
-
if($item === NULL){ $item = ''; }
标签: php laravel laravel-5 laravel-5.4