Home  >  Q&A  >  body text

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>';
}

请问怎么修改啊


PHP中文网PHP中文网2713 days ago2000

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-19 17:00:57

    That is, your item->classes is not an array, but a string. You need to convert item->classes into an array before using it

    reply
    0
  • Cancelreply