【问题标题】:Fatal error: Cannot use string offset as an array in meta.php on line 43致命错误:无法在第 43 行的 meta.php 中使用字符串偏移量作为数组
【发布时间】:2014-03-25 09:55:40
【问题描述】:
Fatal error: Cannot use string offset as an array in /home/content/51/6183951/html/triadss/wp-content/themes/smartbox-installable/lib/functions/meta.php on line 43

请解决这个问题!!!!

meta.php 第 43 行以“array_push”开头

function get_des_templates($type)
{
    global $wpdb;
    $q = "SELECT * from ".$wpdb->prefix."options WHERE option_name LIKE 'des_template_[$type]_%'";
    $res = $wpdb->get_results($q, ARRAY_A);
    $output = array();
    foreach($res as $r)
    {
        $options = unserialize(trim($r['option_value']));
        if (is_string($options))
        {
            $options = unserialize($options);
        }
        array_push($output, array("id"=>$options['des_template_tab']['name'], "name"=>$options['des_template_tab']['nicename']));
    }
    return $output;
}

【问题讨论】:

标签: php arrays string offset


【解决方案1】:

array_push 的第二个参数应该是单个项目(字符串)。

请查看link

尝试使用 array_merge

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    相关资源
    最近更新 更多