为变量分配一个数组改变了类型?

时间:2018-06-06 05:37:08

标签: php arrays wordpress tags

当我将数组分配给变量时,我收到此错误:

  

'krsort()`期望参数1为数组,字符串为

这是我的代码:

    if ( !in_array( $controller, $bypass_controller ) ) {
        $sesscontroller = $this->CI->privileges->getcontrolleruri();
        if ( $sesscontroller && empty( $sesscontroller ) ) {
            $sesscontroller      = $this->CI->session->userdata( SESS_PREFIK . 'controllers' );
            $arrcnt              = array(
                'menu_name'  => 'Add',
                'controller' => ''
            );
            $sesscontroller[]    = $arrcnt;

        } else {
            if ( !is_null( $sesscontroller ) ) {
                krsort( $sesscontroller );
                $this->CI->session->set_userdata( array(
                    SESS_PREFIK . 'controllers' => $sesscontroller
                ) );
            }
        }

为什么我会收到此错误?

1 个答案:

答案 0 :(得分:0)

试试这样。试着解决希望就是工作

<?php
if ( !in_array( $controller, $bypass_controller ) ) {
    $sesscontroller = $this->CI->privileges->getcontrolleruri();
    if ( $sesscontroller && empty( $sesscontroller ) ) {
        $sesscontroller      = $this->CI->session->userdata( SESS_PREFIK . 'controllers' );
        $arrcnt              = array(
            'menu_name'  => 'Add',
            'controller' => ''
        );
        $sesscontroller[]    = $arrcnt;

        if ( !is_null( $sesscontroller ) ) {
            krsort( $sesscontroller );
            $this->CI->session->set_userdata( array(
                SESS_PREFIK . 'controllers' => $sesscontroller
            ) );
        }

    } else {
        // This ELSE part is this line 
        // $sesscontroller = $this->CI->privileges->getcontrolleruri();
        //echo $sesscontroller;
    }
}
?>