首页 >社区问答列表 >php - Warning: in_array() expects parameter 2 to be array

php - Warning: in_array() expects parameter 2 to be array

求助:
报错:Warning: in_array() expects parameter 2 to be array, string given in D:phpStudyWWWzhutiwp-contentthemesthemeprofunctions.php on line 98

出错位置:

if ( $depth == 0 && ($args->depth)>=0 && in_array( 'menu-item-has-children', $item->classes )){
        $class_names[] = 'menu-item-has-children';
        $atts_class[] = 'dropdown-toggle';
        $atts['data-toggle'] = 'dropdown';
        $caret = ' <span class="caret"></span></a>';
    }

请问怎么修改啊

  • PHPzhong
  • PHPzhong    2017-05-16 13:13:531楼

    就是你的item->classes不是数组,是个字符串,需要将item->classes转换成数组在使用

    +0添加回复

  • 回复