Warning: Illegal string offset 'order' in

2019-09-24 08:34发布

问题:

I work with an Wordpress theme which is not being updated. However, the server has a new version of PHP.

The problem is that I can not login to Wordpress; I see these errors:

Warning: Illegal string offset 'order' in /home/minne/domains/civ-lauwersoog.nl/public_html/wp-content/themes/civ/core/functions-core.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/minne/domains/civ-lauwersoog.nl/public_html/wp-content/themes/civ/core/functions-core.php:19) in /home/minne/domains/civ-lauwersoog.nl/public_html/wp-includes/pluggable.php on line 866

This fourth line in the following section is line 19 which generates the error:

function yiw_subval_sort( $a, $subkey ) {
if( is_array( $a ) AND ! empty( $a ) ) {
    foreach( $a as $k => $v ) {
        $b[$k] = strtolower( $v[$subkey] );
    }

    asort( $b );

    foreach( $b as $key => $val ) {
        $c[] = $a[$key];
    }

    return $c;
}

return $a;
}   

I really hope someone could help me out with this issue.

Best Regards,

Peter

回答1:

Try to check if the keys does exist ..

$b and $subkey not defined inside the function you provided.

function yiw_subval_sort( $a, $subkey ) {
    if( is_array( $a ) AND ! empty( $a ) ) {
        foreach( $a as $k => $v ) {
            if( isset( $b[$k] ) && isset( $v[$subkey] ) )
                $b[$k] = strtolower( $v[$subkey] );
    }


标签: php wordpress