错误 代码点火器中的字符串偏移量非法


error illegal string offset in codeigniter

在我看来,我在变量"slug"和"judul"中收到错误非法刺痛偏移。 你能告诉我是什么问题吗?

控制器

function index()
{
    $slug = $this->uri->segment(2);
    $this->data['halaman'] = $this->mhalaman->get_profil($slug);
    if (empty($this->data['halaman'])) {
        show_404();
    }
    $this->data['judul'] = $this->data['halaman']['judul'];
    //var_dump($halaman_item['slug']);
    $this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
    $this->data['contents'] = $this->load->view('page', $this->data, true);
    $this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}

视图

<div class="section ui dropdown link item">
                        <span class="count">Profil</span>
                        <div class="menu">
                            <?php foreach ($halaman as $dt) : ?>
                            <div class="item">
                              <a href="/tkd/index.php/page/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a> //line error
                            </div>
                        <?php endforeach; ?>
                        </div>
                      </div>

模 态

function get_profil($slug = FALSE)
    {
        if ($slug === FALSE)
        {
            $query = $this->db->get($this->tbl_halaman);
            return $query->result_array();
        }
        $query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
        return $query->row_array();
    }

请帮我做什么。谢谢

它应该是echo $dt而不是echo $dt['slug']