1,PHP7中以下代码出现Uncaught Error: Cannot use string offset as an array
$children = ''; foreach ($category as $cid => $cate) { $children[$cate['parentid']][] = $cate; }
原因是$children声明了字符型,下面以数据操作出错,声明为数组即可。
转载请注明:清韵逸-博客生活分享 » 收集PHP中的坑
1,PHP7中以下代码出现Uncaught Error: Cannot use string offset as an array
$children = ''; foreach ($category as $cid => $cate) { $children[$cate['parentid']][] = $cate; }
原因是$children声明了字符型,下面以数据操作出错,声明为数组即可。
转载请注明:清韵逸-博客生活分享 » 收集PHP中的坑