当我点击编辑按钮时,向我显示此错误。此项目来自Github repo
php环境:
PHP 7.1.14(cli)(建于:2018年2月7日18:33:30)(NTS)版权所有(c) 1997-2018 PHP Group Zend Engine v3.1.0,版权所有(c)1998-2018 Zend Technologies
这是220-228,以及此github repo中的完整代码,因为太多代码无法在此处上传
$result = $this->Module_menu_model->select('','*,`menu_id` as id','','list_order ASC,menu_id DESC');
foreach($result as $r) {
$r['cname'] = $r['menu_name'];
$r['selected'] = $r['menu_id'] == $datainfo['parent_id'] ? 'selected' : '';
$array[] = $r;
}
$str = "<option depth='\$depth' value='\$id' \$selected>\$spacer \$cname</option>";
$tree->init($array);
$select_categorys = $tree->get_tree(0, $str);
答案 0 :(得分:1)
对您的代码进行以下更改,然后尝试
$result = $this->Module_menu_model->select('','*,`menu_id` as id','','list_order ASC,menu_id DESC');
$array = array();
foreach($result as $r) {
$r['cname'] = $r['menu_name'];
$r['selected'] = $r['menu_id'] == $datainfo['parent_id'] ? 'selected' : '';
$array[] = $r;
}
$str = "<option depth='\$depth' value='\$id' \$selected>\$spacer \$cname</option>";
$tree->init($array);
$select_categorys = $tree->get_tree(0, $str);
注意$ array变量声明为数组。
答案 1 :(得分:0)
从第216行的列表中删除$ array赋值并分别指定为数组